Skip to content

Error not caught through promises #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cfoulston opened this issue Dec 16, 2015 · 1 comment
Closed

Error not caught through promises #120

cfoulston opened this issue Dec 16, 2015 · 1 comment

Comments

@cfoulston
Copy link

Hi, maybe I'm misunderstanding error handling with Parse Promises, but this is never caught:

Parse.Cloud.define("testError", function (request, response) {

    request.user.fetch().then(function (user) {

        throw "Test Error";

    }).then(function () {

        console.log("Got success");

        response.success(true);

    }, function (error) {

        //This never happens
        console.log("Got error: " + error);

        response.error(error);
    });
});

In my client I receive the error: Parse.ParseException: Uncaught Test Error

How do you handle errors in this way, especially for when an exception is raised at an unknown point?

@andrewimm
Copy link
Contributor

Hi @cfoulston, please read more in #57.

Parse Promises, when they were first implemented, were based on the Promises/A spec (the more modern A+ spec had not been introduced yet). The differences between the two are negligible, with one exception (no pun intended): A+ promises will catch exceptions and not propagate them, A promises will propagate exceptions upwards, stopping execution. From 1.6.8 onwards, we've allowed users to explicitly enable A+ compatibility, and it will be the default in 1.7 and beyond.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants