2015-10-20 61 views
1

我试图运行我的解析云代码作业,但它运行时出现错误。当它遇到这个错误时,它运行function(error)并打印出Got an error undefined : undefinedJavascript错误函数将错误消息记录为'undefined'

由于error宝贵的是未定义的,我很难找出它正在运行的功能之一是导致问题,以及该功能失败的地方。有什么我可以登录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); 
     }); 
}); 
+1

奇怪的是,如果误差是不确定的,则返回Error.message应该引起类似的异常“遗漏的类型错误:无法读取的未定义的属性‘消息’” –

+1

我的想法完全吻合。很奇怪的东西。 – TheDudeGuy

回答

1

发生了什么,我的客户都遇到这个错误是简单地将错误对象转换成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));   
}); 
});