-
-
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
educate people on how to add custom exceptions #324
Comments
The best way I've seen is the way I do it inside raven.js: https://github.com/getsentry/raven-js/blob/master/src/raven.js#L381-L386 Not sure the pros/cons though. :) |
fwiw, I think doing |
Useful. +1 |
There's a great post on how to achieve it: https://coderwall.com/p/m3-cqw/subclassing-error-in-javascript-is-harder-than-it-seems I don't think we will add this to our docs anytime soon, so closing it for now. |
So, borrowed from somewhere on the Internet, we were doing custom exceptions that looked something like this:
Unfortunately if you call
sentry.client.captureError(new ValueError("foobar"))
, Sentry doesn't have the stack trace.Instead you want something like this
It's pretty hacky (well, subclassing exceptions in general is a shit show), but creating a fake error and copying the stack will set the stack trace properly.
Was thinking raven could take the lead here and actually document the right way to create/subclass exceptions so this kind of data doesn't get lost / your Sentry data is more useful.
The text was updated successfully, but these errors were encountered: