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

Preserving cause on rethrown exceptions #1286

Merged
merged 3 commits into from
Feb 19, 2023

Conversation

rPraml
Copy link
Contributor

@rPraml rPraml commented Dec 2, 2022

We had an issue, that we loose the java stack trace, when we catch the error in javascript and rethrow it.

try {
  // call java code
 someJavaObject.doSomething();
} catch (e) {
 // do some error handling and rethrow the error
 throw e;
}

In this case, you will get a JavaScriptException with only the message containing of the exception, that is thrown by someJavaObject.doSomething();
(So you might get a NPE, but you have no idea, which line of code caused the exception)

In this PR, we try to set the currently processing exception/NativeError and setting it as cause of the JavaScriptException.

Roland

@rbri
Copy link
Collaborator

rbri commented Dec 4, 2022

LGTM - great improvement.

@rbri
Copy link
Collaborator

rbri commented Dec 21, 2022

@gbrail @p-bakker can i merge this?

@rbri
Copy link
Collaborator

rbri commented Feb 19, 2023

@rPraml thanks for this

@rbri rbri merged commit 3412fc5 into mozilla:master Feb 19, 2023
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.

2 participants