Stringify error data structs (#1426)

This commit is contained in:
Jaco Greeff
2019-09-28 09:44:35 +02:00
committed by GitHub
parent 0bc0ef6110
commit 25f78a7354
+2 -2
View File
@@ -4,7 +4,7 @@
import { JsonRpcRequest, JsonRpcResponse, JsonRpcResponseBaseError } from '../types';
import { assert, isUndefined, isNumber } from '@polkadot/util';
import { assert, isUndefined, isNumber, isString } from '@polkadot/util';
export default class RpcCoder {
private id = 0;
@@ -54,7 +54,7 @@ export default class RpcCoder {
const { code, data, message } = error;
const _data = isUndefined(data)
? ''
: ' (' + `${data}`.substr(0, 10) + ')';
: `: ${isString(data) ? data : JSON.stringify(data)}`.substr(0, 22);
throw new Error(`${code}: ${message}${_data}`);
}