[英]Javascript error function is logging the error message as 'undefined'
我正在嘗試運行我的Parse雲代碼作業,但是它遇到了錯誤。 遇到此錯誤時,它將運行function(error)
並打印出Got an error undefined : 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);
});
});
對於遇到此錯誤的客戶來說,行之有效的方法是將錯誤對象簡單地轉換為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));
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.