-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Compare ignoreErrors pattern to error message #1076
Compare ignoreErrors pattern to error message #1076
Conversation
@benvinegar this also resolves your concern from here #1057 (comment) |
src/raven.js
Outdated
this._globalOptions.ignoreErrors.test(testString) | ||
!!this._globalOptions.ignoreErrors.test && ( | ||
this._globalOptions.ignoreErrors.test(message) || | ||
this._globalOptions.ignoreErrors.test(testString)) |
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.
Can we also change it so that testString
doesn't become :message
if it's undefined? per #1075 (comment)
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.
Yep! Addressed.
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 code will double-check the same string if type
is not defined, but I think we can live with it.
Although an alternative would be something like this, which also do the job, but doesn't improve a readability really
if (!!this._globalOptions.ignoreErrors.test) {
var testString = (type ? type + ': ' : '') + (message || '')
if (this._globalOptions.ignoreErrors.test(message)) return
if (testString !== message && this._globalOptions.ignoreErrors.test(testString)) return
}
I can live with the code we have now.
@staticshock could you please add one quick test to make sure both scenarios work? https://github.com/getsentry/raven-js/blob/master/test/raven.test.js#L478-L490 Some of the scenarios where it should match:
|
@kamilogorek how do you feel about this? |
@staticshock I think that in the end, initial version was more readable, so let's stick with it. if (
!!this._globalOptions.ignoreErrors.test && (
this._globalOptions.ignoreErrors.test(message) ||
this._globalOptions.ignoreErrors.test(stringifiedError))
) Other then this all looks good! Thanks for updating tests :) |
✅ |
Thanks! :) |
This resumes filtering opaque "Script error" messages caused by errors in cross-origin scripts.
Fixes #1075.