-
Notifications
You must be signed in to change notification settings - Fork 11
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
Question: Why use .catch on the promise #9
Comments
@terenced can you tell me why?thank you |
The When there's an exception thrown during a Promise, it will not be caught by a try { new Promise(() => { throw new Error('Hey') }) } catch (e) { console.log(e) }
Flow-wise, that is still an unsuccessful promise execution, so this library should execute the This solution also doesn't interfere with you defining your custom new Promise(() => { throw new Error('Hey') }).catch(e => console.log('Custom', e)).catch(e => console.log('Library', e)) |
@kettanaito Thank you! |
@kettanaito I think this might be incorrect - In your example you're just missing an try { await new Promise(() => { throw new Error('Hey') }) } catch (e) { console.log(e) } |
I am curious why this change was introduced.
Is there a benefit of calling
.catch
on the promise? It is my understanding that the catch block would handle throws?The text was updated successfully, but these errors were encountered: