我正在尝试运行我的 Parse 云代码作业,但遇到错误。当遇到此错误时,它会运行 function(error)
并打印出 Got an error undefined : undefined
。
由于 error
value 未定义,我很难确定它正在运行的哪个函数导致了问题,以及该函数中的哪个位置失败了。我可以登录 status.error
来查看发生了什么问题吗?
Parse.Cloud.job("MCBackground", function(request, status) {
// ... other code to setup usersQuery ...
Parse.Cloud.useMasterKey();
var usersQuery = new Parse.Query(Parse.User);
return usersQuery.each(function(user) {
return processUser(user)
.then(function(eBayResults) {
return mcComparison(user, eBayResults);
});
})
.then(function() {
// Set the job's success status
status.success("MatchCenterBackground completed successfully.");
}, function(error) {
// Set the job's error status
status.error("Got an error " + error + " : " + error.message);
});
});
最佳答案
对于遇到此错误的客户来说,最有效的方法是简单地将错误对象转换为 JSON,然后将该错误作为字符串处理,例如通过将错误记录到控制台。
Parse.Cloud.job("MCBackground", function(request, status) {
// ... other code to setup usersQuery ...
Parse.Cloud.useMasterKey();
var usersQuery = new Parse.Query(Parse.User);
return usersQuery.each(function(user) {
return processUser(user)
.then(function(eBayResults) {
return mcComparison(user, eBayResults);
});
})
.then(function() {
// Set the job's success status
status.success("MatchCenterBackground completed successfully.");
}, function(error) {
// Set the job's error status
status.error("Got an error " + JSON.stringify(error));
});
});
关于Javascript 错误函数将错误消息记录为 'undefined',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33226160/