Skip to content
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

Fix exception rethrow #6933

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DZakh
Copy link
Contributor

@DZakh DZakh commented Aug 4, 2024

Fixes #6929

Copy link
Contributor Author

@DZakh DZakh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few places to fix, but this is how I see the solution for the issue.

throw new Error(exn.RE_EXN_ID, {
cause: exn
});
throw exn;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should throw raw_exn instead

Comment on lines 94 to 97
catch (raw_exn){
let exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
if (exn.RE_EXN_ID === A) {
if (exn._1 === 3) {
return;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it worth renaming to:

Suggested change
catch (raw_exn){
let exn = Caml_js_exceptions.internalToOCamlException(raw_exn);
if (exn.RE_EXN_ID === A) {
if (exn._1 === 3) {
return;
}
catch (exn) {
let exnCause = Caml_js_exceptions.internalExnToCause(exn);
if (exnCause.RE_EXN_ID === A) {
if (exnCause._1 === 3) {
return;
}
throw exn

_1: 3
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be generated as new Error("A", { cause: {...} }) instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v12-alpha: The raise call started recreating exn, which breaks try/catch
1 participant