Files
common/packages/util/docs/ext.md
T
Jaco Greeff b5c5734c7c Add Blake2s & XXHash utility functions (#66)
* Initial split of util & util-crypto

* Add initial XXHash version

* Blake2s wit tests & documentation

* Add sha512 (from NaCl)

* Add randomBytes (from NaCl)

* Flow fixes

* Update documentation

* Update latest @polkadot/dev
2018-01-25 14:13:43 +01:00

22 lines
613 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` (mixed 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
```