-
Notifications
You must be signed in to change notification settings - Fork 448
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
base: master
Are you sure you want to change the base?
Fix exception rethrow #6933
Conversation
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.
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; |
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.
It should throw raw_exn
instead
jscomp/test/equal_exception_test.js
Outdated
catch (raw_exn){ | ||
let exn = Caml_js_exceptions.internalToOCamlException(raw_exn); | ||
if (exn.RE_EXN_ID === A) { | ||
if (exn._1 === 3) { | ||
return; | ||
} |
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 see it worth renaming to:
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 |
jscomp/test/equal_exception_test.js
Outdated
_1: 3 | ||
}; |
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.
This should be generated as new Error("A", { cause: {...} })
instead
Fixes #6929