We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Using Promise 4.0.1, when I run the following code:
Promise(function(resolve, reject){ throw "hello" }) .fail(function(err){ server.error("fail: " + err); })
The fail handler catches the error and I get this output, which is what I would expect: ERROR: fail: hello
ERROR: fail: hello
However, if I change the code so that it has an inner promise that throws:
Promise(function(resolve, reject){ return Promise(function(resolve2, reject2){ throw "hello" }) }) .fail(function(err){ server.error("fail: " + err); })
I would still expect the same output, but now I get Unhandled promise rejection: hello
Unhandled promise rejection: hello
I get the same behavior if I use a Promise.reject instead of throw:
Promise(function(resolve, reject){ return Promise.reject("hello") }) .fail(function(err){ server.error("fail: " + err); })
If I now add another fail handler:
Promise(function(resolve, reject){ return Promise(function(resolve2, reject2){ throw "hello" }) .fail(function(err){ server.error("inner fail: " + err); throw err; }) }) .fail(function(err){ server.error("fail: " + err); })
I get:
ERROR: inner fail: hello Unhandled promise rejection: hello
The workaround I have found is to setup my promises like this:
Promise.resolve(null).then(function(_){ return Promise(function(resolve2, reject2){ throw "hello" }) .fail(function(err){ server.error("inner fail: " + err); throw err; }) }) .fail(function(err){ server.error("fail: " + err); })
now I get the output I would expect:
ERROR: inner fail: hello ERROR: fail: hello
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Using Promise 4.0.1, when I run the following code:
The fail handler catches the error and I get this output, which is what I would expect:
ERROR: fail: hello
However, if I change the code so that it has an inner promise that throws:
I would still expect the same output, but now I get
Unhandled promise rejection: hello
I get the same behavior if I use a Promise.reject instead of throw:
If I now add another fail handler:
I get:
The workaround I have found is to setup my promises like this:
now I get the output I would expect:
The text was updated successfully, but these errors were encountered: