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
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);
MIT