title: Handling specific errors in JavaScript (think exceptions)
body: <p>How would you implement different types of errors, so you'd be able to catch specific ones and let others bubble up..?
  <br /><br />
  One way to achieve this is to modify the prototype of the <code>Error</code> object:</p>
  
  <pre><code>Error.prototype.sender = "";
  
  
  function throwSpecificError()
  {
      var e = new Error();
  
      e.sender = "specific";
  
      throw e;
  }
  </code></pre>
  
  <p>Catch specific error:</p>
  
  <pre><code>try
  {
      throwSpecificError();
  }
  
  catch (e)
  {
      if (e.sender !== "specific") throw e;
  
      // handle specific error
  }
  </code></pre>
  
  <p><br />
  Have you guys got any alternatives?</p>