Files
common/docs/ext.md
T
Jaco Greeff 5d0a7231dc Fix alias links (#34)
* Fix alias links

* Update alias links

* Update generated docs
2017-12-01 20:34:51 +01:00

22 lines
611 B
Markdown

# ext
Extensions to basic classes
- [ExtError](#exterror) Extension to the basic JS Error.
## ExtError
Extension to the basic JS Error.
```js
ExtError (message: string = '', code: number = UNKNOWN_ERROR, value: any)
```
The built-in JavaScript Error class is extended by adding a code to allow for Error categorization. In addition to the normal `stack`, `message`, the numeric `code` and `data` (any types) parameters are available on the object.
```js
const { ExtError } = require('@polkadot/util');
throw new ExtError('some message', ExtError.CODES.METHOD_NOT_FOUND); // => error.code = -32601
```