- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.7k
Closed
Description
So, borrowed from somewhere on the Internet, we were doing custom exceptions that looked something like this:
var ValueError;
ValueError = (function() {
  function ValueError() {}
  ValueError.prototype = Object.create(Error.prototype);
  return ValueError;
})();
module.exports = ValueError;Unfortunately if you call sentry.client.captureError(new ValueError("foobar")), Sentry doesn't have the stack trace.
Instead you want something like this
var ValueError;
ValueError = (function() {
  function ValueError(message) {
    this.message = message;
    this.stack = new Error(this.message).stack;
  }
  ValueError.prototype = Object.create(Error.prototype);
  return ValueError;
})();
module.exports = ValueError;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.
Metadata
Metadata
Assignees
Labels
No labels