Closed kjvalencik closed 9 months ago
.then
can take a rejection handler as a second argument. This is a somewhat simpler option.
Ideally, we also wouldn't need to create new JsFunction
wrapping Rust on each to_future
, but the only alternative I can think of is .bind(..)
.
Previously, Neon was creating a distinct promise chain for handling resolved promises in
JsPromise::to_future
. This is problematic because it causes anunhandledRejection
, even though the user may be handling the error.In other words, it was the equivalent of this JavaScript:
Instead, we use the two argument version of
.then(onResolved, onRejected)
which accepts both handlers at once, acting sort of like amatch result
. It is equivalent to the following JavaScript: