Javascript Snippet

class RequestError {
  constructor(detail) {
    this.detail = detail;
    this.message = `${this.detail.statusText}, ${this.detail.status}`;
  }
}

RequestError.prototype = Error.prototype;
function CheckError(name, message) {
  this.name = name;
  this.message = message || 'Default Message';
  this.stack = (new Error()).stack;
}
CheckError.prototype = Object.create(Error.prototype);
CheckError.prototype.constructor = CheckError;

https://stackoverflow.com/questions/783818/how-do-i-create-a-custom-error-in-javascript

Error within error code which make statement can use error code to response specific error behaviour

Last updated

Was this helpful?