Package Exports
- @carnesen/coded-error
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@carnesen/coded-error) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@carnesen/coded-error
An Error
class with additional properties "code" and "data"
Install
$ npm install @carnesen/coded-error
This package includes runtime JavaScript files (ES2015) and the corresponding TypeScript type declarations.
Usage
import { CodedError } from '@carnesen/coded-error';
const err = new CodedError('An error has occurred', 127, { foo: 'bar' });
console.log(err);
/*
{ CodedError: An error has occurred
at Object.<anonymous> (/Users/carnesen/GitHub/coded-error/example.js:3:13)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
code: 127, data: { foo: 'bar' } }
*/
API
The constructor signature is:
new CodedError(message: string, code: any, data: any);
This creates an object with properties message
, code
, and data
. Besides that there's not much to know!
More information
If you encounter any bugs or have any questions or feature requests, please don't hesitate to file an issue or submit a pull request on this project's repository on GitHub.
License
MIT © Chris Arnesen