title: Is there a way in es6 to inherit from Error and not have the constructor in the stacktrace?
body: <p>I tried to write a <code>HTTPError</code> class by extending Error:</p>
  
  <pre><code>class HTTPError extends Error {
     constructor(codeArg, message){
        let code = codeArg || 500;
        super(message || http.STATUS_CODES[code]); // first line in stack trace
        this.code = code;
     }
  }
  </code></pre>
  
  <p>This works mostly fine, but when I <code>throw</code> such an error, the line where <code>super</code> is called, is the first line in the stack trace (assuming nodejs):</p>
  
  <pre><code>&gt; const HTTPError = require('./HTTPError')
  undefined
  &gt; let e = new HTTPError(418)
  undefined
  &gt; throw e
  Error: I'm a teapot
      at HTTPError (/home/pat/Scripts/js/HTTPError.js:6:6)
      at repl:1:9
      at sigintHandlersWrap (vm.js:32:31)
      at sigintHandlersWrap (vm.js:96:12)
      at ContextifyScript.Script.runInContext (vm.js:31:12)
      at REPLServer.defaultEval (repl.js:308:29)
      at bound (domain.js:280:14)
      at REPLServer.runBound [as eval] (domain.js:293:12)
      at REPLServer.&lt;anonymous&gt; (repl.js:489:10)
      at emitOne (events.js:101:20)
  &gt; e.code
  418
  </code></pre>
  
  <p>The first line of the stack trace is in the constructor of <code>HTTPError</code>. The interesting one (the one where it was created) is the second <code>repl:1:9</code> line. Is there a way around this?</p>