title: Intentionally create new error in Javascript to check code behavior
body: <p>In order to test how the front-end responds to various HTTP status error codes, I want to intentionally return an Error from one of my front-end service methods to simulate an Error from one of the API endpoints. The question is... how to do it in a more detailed manner.</p>
  
  <p>I tried using the <code>new Error()</code> constructor, but I can see that I just have the option to add a message as argument to the constructor. I would also want to mock a status code, like for example <code>500</code>.</p>
  
  <p>The question that was pointed as a potential solution, <a href="https://stackoverflow.com/questions/783818/how-do-i-create-a-custom-error-in-javascript">How do I create a custom Error in JavaScript?</a>, does not solve my problem. In the question and answers it is mentioned that the person wants to simply throw a new error with a name and a message, while I would also want to be able to throw different Error codes.</p>