forked from EOSIO/eosjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheosjs-rpcerror.ts
28 lines (26 loc) · 998 Bytes
/
eosjs-rpcerror.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* @module RPC-Error
*/
// copyright defined in eosjs/LICENSE.txt
/** Holds detailed error information */
export class RpcError extends Error {
/** Detailed error information */
public json: any;
public details: any;
constructor(json: any) {
if (json.error && json.error.details && json.error.details.length && json.error.details[0].message) {
super(json.error.details[0].message);
this.details = json.error.details;
} else if (json.processed && json.processed.except && json.processed.except.message) {
super(json.processed.except.message);
this.details = json.processed.except;
} else if (json.result && json.result.except && json.result.except.message) {
super(json.result.except.message);
this.details = json.result.except;
} else {
super(json.message);
}
Object.setPrototypeOf(this, RpcError.prototype);
this.json = json;
}
}