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

Optionally guess error class when missing #779

Merged
merged 1 commit into from
Sep 9, 2019

Conversation

waltjones
Copy link
Contributor

Fixes: https://app.clubhouse.io/rollbar/story/54135/rollbar-js-exception-class

Previously, when error.name and error.constructor.name are both missing, error.message would be used to guess the class, using a regex to look for and extract the part before the colon.

This has unintended results most of the time. In cases where the name property is missing, it is unlikely the class will be in the message string. Meanwhile, it's possible for other strings to match the regex and generate unexpected values that get assigned to be the error class. Besides being confusing and not useful, this interferes with grouping.

This PR makes the default behavior to assign "(unknown)" as the error class. This is the value already being used when no value can be guessed.

When config.guessErrorClass is set, this engages the old behavior. For any users who are intentionally adding error classes to their message strings, setting this will allow them to be extracted. Note that as before, this only happens when both error.name and error.constructor.name are missing.

@waltjones waltjones merged commit 7741316 into master Sep 9, 2019
mudetroit pushed a commit that referenced this pull request Mar 14, 2024
Optionally guess error class when missing
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.

1 participant