Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

11
  • 17
    I don't think Firefox actually has captureStackTrace. It's a V8 extension and is undefined in Firefox for me, nor can I find any references on the web to Firefox supporting it. (Thanks though!)
    – Geoff
    Commented Feb 23, 2012 at 7:37
  • 6
    Error.call(this) is indeed not doing anything since it returns an error rather than modifying this. Commented Oct 2, 2012 at 10:13
  • 1
    UserError.prototype = Error.prototype is misleading. This doesn't do inheritance, this makes them the same class.
    – Halcyon
    Commented Nov 21, 2013 at 13:10
  • 1
    I believe Object.setPrototypeOf(this.constructor.prototype, Error.prototype) is preferred to this.constructor.prototype.__proto__ = Error.prototype, at least for current browsers.
    – ChrisV
    Commented Mar 20, 2015 at 12:54
  • 1
    Why not this.constructor.prototype = Object.create(Error.prototype);? Seems cleaner than using __proto__
    – timruffs
    Commented Oct 28, 2015 at 12:03