Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript error function is logging the error message as 'undefined'

I'm attempting to run my Parse cloud code job, however it's running into an error. When it hits this error, it runs function(error) and prints out Got an error undefined : undefined.

Because the error valuable is undefined, I'm having a hard time figuring out which one of the functions it's running is causing the problem, as well as where in that function it's failing. Is there anything I can log in status.error to see what's going wrong?

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);
        });
});
like image 871
Andrew Avatar asked Mar 17 '26 09:03

Andrew


1 Answers

What has worked well for my clients that are experiencing this error is to simply convert the error object into JSON then work with that error as a string e.g. by logging the error to the console.

    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));         
}); 
});
like image 184
Henry Situ Avatar answered Mar 18 '26 22:03

Henry Situ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!