Files
common/docs/ext.md
T
Jaco Greeff b4c67178a1 Add isError & ExtError (#16)
* Add isError & ExtError

* Check fixes

* Check fixes
2017-11-24 20:49:25 +01:00

610 B

ext

Extensions to basic classes

  • ExtError Extension to the basic JS Error.

ExtError

Extension to the basic JS Error.

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.

const { ExtError } = require('@polkadot/util');

throw new ExtError('some message', ExtError.CODES.METHOD_NOT_FOUND); // => error.code = -32601