3.4 KiB
name: ExtError
signature: ExtError (message: string = '', code: number = UNKNOWN_ERROR, value: any)
summary: Extension to the basic JS Error.
description: 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.
example:
const { ExtError } from '@polkadot/util');
throw new ExtError('some message', ExtError.CODES.METHOD_NOT_FOUND); // => error.code = -32601
Hierarchy
Error
↳ ExtError
Implements
ExtErrorInterface
Constructors
constructor
⊕ new ExtError(message?: string, code?: number, data?: any): ExtError
Defined in ext/error.ts:44
Parameters:
| Name | Type | Default value |
|---|---|---|
Default value message |
string |
"" |
Default value code |
number |
UNKNOWN |
Optional data |
any |
- |
Returns: ExtError
Properties
code
● code: number
Defined in ext/error.ts:36
data
● data: any
Defined in ext/error.ts:38
message
● message: string
Overrides Error.message
Defined in ext/error.ts:40
name
● name: string
Overrides Error.name
Defined in ext/error.ts:42
stack
● stack: string
Overrides Error.stack
Defined in ext/error.ts:44
<Static> Error
● Error: ErrorConstructor
Defined in /home/travis/build/polkadot-js/common/node_modules/typescript/lib/lib.es5.d.ts:914
Object literals
<Static> CODES
CODES: object
Defined in ext/error.ts:61
ASSERT
● ASSERT: number = -90009
Defined in ext/error.ts:62
INVALID_JSONRPC
● INVALID_JSONRPC: number = -99998
Defined in ext/error.ts:64
METHOD_NOT_FOUND
● METHOD_NOT_FOUND: number = -32601
Defined in ext/error.ts:65
UNKNOWN
● UNKNOWN: number
Defined in ext/error.ts:63