-
Notifications
You must be signed in to change notification settings - Fork 287
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
try_catch #543
try_catch #543
Conversation
…till left to do: - hide the public API (and tests) behind a feature flag - add tests for nested `TryCatch` instances on the stack - add panic handler and tests to ensure panics get caught by try_catch
- Implement panic propagation - Add tests for panic and regular return value
… for the dynamic tests.
…ic `try_catch` API.
@@ -226,6 +226,22 @@ pub trait Context<'a>: ContextInternal<'a> { | |||
result | |||
} | |||
|
|||
#[cfg(all(feature = "try-catch-api", feature = "napi-runtime"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: For the final documented version, it would be beneficial to include the behavior that this method will panic
if a user manually constructs an Err(Throw)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, when we un-feature-gate it, it'll need API docs. In the meantime I'll make sure that gets added to the RFC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to add an Exceptions
section to the guides docs soon
This PR implements the
cx.try_catch
API of RFC 29. I had to make a few changes to the signature oftry_catch
to make the types work out; I'll update the RFC to match.Still left to do:
TryCatch
instances on the stackMaybeUninit
instead ofmem::zeroed()
Box
and the "unlikely" branchundefined
on unexpectedErr(Throw)
T: Value
instead ofJsValue