title: Custom error classes not extending correctly
body: <p>I have a couple of custom error classes</p>
  
  <p>GenericError.js</p>
  
  <pre><code>import { errorCodes, errorMessages } from './errorConstants';
  
  class GenericError extends Error {
      constructor(message = errorMessages.UNKNOWN, code = errorCodes.UNKNOWN, description) {
        super();
        Error.captureStackTrace(this, this.constructor);
        this.name = this.constructor.name;
        this.message = message;
        this.code = code;
        this.description = description;
      }
  
      stringify() {
          return JSON.stringify({
              error : {
                  message: this.message || "Unknown Error.",
                  code: this.code,
                  description: this.description
              },
          })
      }
  }
  
  export default GenericError;
  </code></pre>
  
  <p>NotFoundError.js</p>
  
  <pre><code>import GenericError from "./GenericError";
  import {errorMessages, errorCodes} from "./errorConstants";
  
  class NotFoundError extends GenericError {
      constructor(message = errorMessages.NOT_FOUND, code = errorCodes.NOT_FOUND, description = "Not Found.") {
          super(message, code, description);
          this.name = this.constructor.name;
       }
  
  }
  
  export default NotFoundError;
  </code></pre>
  
  <p>However, when I use this function</p>
  
  <pre><code>firebaseUtils.getInfo(user)
      .then((info) =&gt; {
          const infoSnapshot = info || {};
          if (//some logic here) {
              throw new NotFoundError();
          }
          response.send(JSON.stringify(infoSnapshot));
      })
      .catch((error) =&gt; {
          if(error.name === "NotFoundError") {
              response.status(error.getCode).send(error.stringify());
              return;
          }
  
  
      })
  </code></pre>
  
  <p>When I throw new NotFoundError(), For some reason, error.name is <code>Error</code> instead of <code>NotFoundError</code> and stringify is not a function?</p>
  
  <p>Can anybody tell me whats wrong?</p>
  
  <p>EDIT: Removed typescript from my code and its not working!</p>