-
-
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
"Non-Error exception captured with keys: [...]" due to invalid error instanceof check #6332
Comments
Hey @theofidry thanks for writing in. I think you're right that we can re-evaluate the angular error handler logic here. We can change the instance check, but ideally we make sure that errors have a Also cc @Lms24 here to comment on some of the Angular specific things. |
I agree, we should get rid of the instance check (type guard sounds like a good suggestion) and try to make the behaviour similar to No idea though, why the output looks so different between sentry-javascript/packages/browser/src/integrations/globalhandlers.ts Lines 76 to 106 in a93cd23
Admittedly without looking too closely, my guess is that the difference comes from the Gonna backlog this for now for the |
Thanks a lot for the replies!
Is it really necessary? At the very least from this code and that one, it looks like that strings at least are fine. So if I understand correct, it could be an error-like object without the stack, but it needs at the very least the message.
@Lms24 is there any chance/recommendation as too how to hook the Angular error handler instead of this? Or do they need to be different? It might not be too much of a problem if a parity is provided with the native code (the one attached to the window and the angular error handler), but this sounds hard and I also struggle to see how it would work if one extends the error handler. |
I think what @AbhiPrasad meant was that having a stack trace is better than not having one, as it just provides a lot more context around the captured error. The Angular
You mean you'd like to capture errors captured in Btw, if you want to change how errors are extracted from the Angular ErrorHandler, you can pass a custom extractor to the ErrorHandler's constructor |
Thanks a lot for the reply. I'll give another try at the handling of strings. If it works on your side, since the code is up to date, the last possible culprit is that our Sentry instance is faulty or there is a weird ignore rule or something. I didn't really think of that when I posted the issue, I will check. Otherwise it looks at the very least that we all agree on the undesired instance of Error. So I can do a PR for that. |
Add more tests to cover the problematic paths mentioned in #6332.
Closes getsentry#6332. As discussed in the linked issue, it is more beneficial to handle error shaped objects instead of just instances of `Error`s.
We just released this change with version |
Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which package are you using?
@sentry/angular
SDK Version
7.7.0
Framework Version
Angular 13.3 & Ionic 5
Link to Sentry event
No response
Steps to Reproduce
Expected Result
The first problem I identify here is the incorrect handling of error like objects. I suspect this is due to this line:
I am really not convinced an
instanceof
should be used here. Having a type guard to check for an error like object (it could also have a quick instanceof under the hood), would make more sense and also be more in line with the philosophy of TypeScript where types are checked as structures, instead of instances.The second problem I see is the difference of handling when an error is thrown, captured by Sentry manually or passed to the error handler.
That there is a difference between
Sentry.captureException()
andErrorHandler.handle()
makes sense since the latter is using the former under the hood. But I think having a difference of handling for when an error is thrown instead of passed to the error handler is a lot more surprising.I however could not find where the global listener is registered and check the problematic code or figure out a way to fix this.
Actual Result
// Case1: capture string
Nothing captured!
// Case2: capture error-like object
// Case3: throw string
Nothing captured!
// Case4: throw error-like object
// Case5: capture string with the SentryAngular ErrorHandler
Nothing captured!
// Case6: capture error-like object with the SentryAngular ErrorHandler
Nothing captured!
The text was updated successfully, but these errors were encountered: