spudly / error-wrapper

💣 A base class for creating custom JavaScript error classes that wrap around a child error object.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ErrorWrapper

A Base Class for creating error objects that wrap around other error objects without trashing the stack trace of the original error. Stack traces will appear in the following format:

ERROR MyCustomErrorWrapper Some Error Message
  at /path/to/some/js/file.js:123:456
  at /path/to/some/other/js/file.js:123:456
...
Caused By: Error: Some Other Error Message
  at /path/to/some/js/file.js:123:456
  at /path/to/some/other/js/file.js:123:456

All the Badges...

NPM

Build Status

js-semistandard-style

Dependencies DevDependencies

Usage

import ErrorWrapper from 'error-wrapper';

class MyErrorWrapper extends ErrorWrapper {

  // Add extra properties/methods if desired:

  get code() {
    return 'MYERRORWRAPPER';
  }

}

// later...
throw new MyErrorWrapper('error message', originalError);

License

MIT

About

💣 A base class for creating custom JavaScript error classes that wrap around a child error object.

License:MIT License


Languages

Language:JavaScript 100.0%