You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Essentially, Promise.prototype.then allows taking in two arguments to respond to both resolved and rejected promises. Essentially, p.then(f, g) is equivalent to p.catch(g).then(f); note that the catch comes first since errors thrown by the then handler are not caught by the catch handler.
It would be nice to automatically replace instances like this since it makes it easier to visually scan for catch to check if an error is handled. It also helps emphasise the fact that the then is not handled by the catch, which isn't as apparent when it's ordered visually after the then handler.
The text was updated successfully, but these errors were encountered:
To clarify, I mean that then(f, g) is equivalent to catch(g).then(f) always, so it can be auto-applied. But the exact ordering of then and catch is up to the user. So, if any automatic combining or splitting is done, it has to be done for things in that order, because otherwise it might change the functionality.
Essentially,
Promise.prototype.then
allows taking in two arguments to respond to both resolved and rejected promises. Essentially,p.then(f, g)
is equivalent top.catch(g).then(f)
; note that the catch comes first since errors thrown by thethen
handler are not caught by thecatch
handler.It would be nice to automatically replace instances like this since it makes it easier to visually scan for
catch
to check if an error is handled. It also helps emphasise the fact that thethen
is not handled by thecatch
, which isn't as apparent when it's ordered visually after thethen
handler.The text was updated successfully, but these errors were encountered: