Optionally guess error class when missing #779
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: https://app.clubhouse.io/rollbar/story/54135/rollbar-js-exception-class
Previously, when
error.name
anderror.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 botherror.name
anderror.constructor.name
are missing.