title: How do I create a custom Error in JavaScript?
body: <p>For some reason it looks like constructor delegation doesn't work in the following snippet:</p>
  
  <pre><code>function NotImplementedError() { 
    Error.apply(this, arguments); 
  }
  NotImplementedError.prototype = new Error();
  
  var nie = new NotImplementedError("some message");
  console.log("The message is: '"+nie.message+"'")
  </code></pre>
  
  <p>Running this gives <code>The message is: ''</code>. Any ideas as to why, or if there is a better way to create a new <code>Error</code> subclass? Is there a problem with <code>apply</code>ing to the native <code>Error</code> constructor that I don't know about?</p>