Skip to content

Throwing a custom error objects sets culprit / last stack frame to error message #1209

@vicrep

Description

@vicrep

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:

export class CustomError extends Error {
  name = 'CustomError';
  constructor(...args) {
    super(...args);
    Error.captureStackTrace(this, Error);
  }
}

Now, throwing the custom error (throw new CustomError('my error message')) and inspecting the data sent (through dataCallback, we noticed that both data.culprit and the last frame in data.exception.values[0].stacktrace.frames both point to the filename CustomError 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions