-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Throwing a custom error objects sets culprit / last stack frame to error message #1209
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
Comments
Hey @vicrep, this should be covered by TraceKit that we use. However, I see that you're not creating export class SentryError extends Error {
public name: string;
constructor(public message: string) {
super(message);
this.name = new.target.prototype.constructor.name;
Object.setPrototypeOf(this, new.target.prototype);
}
} |
@kamilogorek thanks for getting back to me. So I took the time to try your suggested fix, and ended up discovering what was causing the actual issue. Prototype chain assignments were actually being handled by the typescript compiler, so doing In my issue request, I wrote Here's an example, where I have two custom errors, declared in the same file, which share the exact same implementation -- one is named Throwing Now, throwing the error So it seems something is happening in the pipeline when errors' class names begin with Http |
Well, that's definitely unexpected behavior haha. Thanks for the investigation. I wonder if it's TypeScript compiler then or some part of your Webpack config. Are you able to provide some minimal reprop case that I could use to fiddle with it? It'd be nice to find the main cause for a future reference. |
Hey @kamilogorek I checked with my TypeScript compiler, and the generated classes were the exact same for Here's a repro for you. Note that what actually triggers the wrong stack trace is when the |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
A project I work on (in typescript) defines custom ES6 errors as such:
Now, throwing the custom error (
throw new CustomError('my error message')
) and inspecting the data sent (throughdataCallback
, we noticed that bothdata.culprit
and the last frame indata.exception.values[0].stacktrace.frames
both point to the filenameCustomError my error message
, with the file which throws the error being the second last entry in the stacktrace.In comparison, throwing a standard error yields a
data.culprit
and last stacktrace frame both pointing to whichever file threw the error.What is the expected behavior?
Custom errors should be handled the same way as standard errors. We believe the impact of this is that it prevents proper grouping of those custom errors, and we went around this by popping the last stacktrace frame and overriding the culprit in the
dataCallback
when this scenario is detected.Using Raven.JS 3.22.1, installed through NPM.
The text was updated successfully, but these errors were encountered: