Skip to content

ref(minimal): Simplify syntheticException creation #4691

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

Merged
merged 1 commit into from
Mar 8, 2022

Conversation

Turbo87
Copy link
Contributor

@Turbo87 Turbo87 commented Mar 8, 2022

Whether the error is thrown or not does not matter because stacktraces are generated when new Error() is called. In other words: the try-catch in captureException() and captureMessage() is unnecessary, and we can assign the new Error instance directly.

You can verify this by running the following snippet somewhere in your code:

let e = new Error('bla');
console.log(e);

try {
  throw new Error('bla');
} catch (error) {
  console.log(error);
}

Before submitting a pull request, please take a look at our Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).

Whether the error is thrown or not does not matter because stacktraces are generated when `new Error()` is called. In other words: the try-catch in `captureException()` and `captureMessage()` is unnecessary, and we can assign the new `Error` instance directly.
@kamilogorek
Copy link
Contributor

This branch of code is now 6 years old, and it comes from the ancient raven-js. I believe oooold old browsers did not create the stack when creating the Error object, thus this solution - #582
But I think it should be fine in the present times.

Copy link
Member

@lobsterkatie lobsterkatie left a comment

Choose a reason for hiding this comment

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

Nice.

@lobsterkatie lobsterkatie changed the title minimal: Simplify syntheticException creation ref(minimal): Simplify syntheticException creation Mar 8, 2022
@lobsterkatie lobsterkatie merged commit 008982f into getsentry:master Mar 8, 2022
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.

3 participants