Trigger `catch`/`finally` with rejected `return` promise in `async` functions

Isiah Meadows isiahmeadows at gmail.com
Sun Sep 9 19:30:00 UTC 2018


I know this requires a bit of an exception, but I feel
`catch`/`finally` should trigger when a promise `return`ed from an
`async` function rejects. It just seems incredibly odd not to, since
the usual intuition is that if an error occurs during the execution of
a function, it's catchable by the parent via `try`/`catch`, even if
it's a simple `return foo(...args)`. You see that a lot with the
`return await foo(...args)` step necessary within `try`/`catch` blocks
in async functions, but that's literally the only time that idiom is
necessary - it's otherwise generally equivalent to `return
foo(...args)` mod timings, including when returning directly outside
them.

Could you all in TC39 fix this to work a little more intuitively?

-----

Isiah Meadows
contact at isiahmeadows.com
www.isiahmeadows.com


More information about the es-discuss mailing list