client-js
client-js copied to clipboard
Original error object is not available in thrown error
Describe the bug
It is possible to catch a thrown JSONRPCError
object on failure, but the original error from the request (e.g., over HTTP) is lost, after a number of re-creations of the error during processing. See instances of new JSONRPCError
in the codebase.
To Reproduce Steps to reproduce the behavior:
- Make a json-rpc request which returns an error.
- Observe the returned error object is of the shape:
{
"code": 7979,
"data": {
"code": 7979,
"data": "{\"jsonrpc\":\"2.0\",\"id\":null,\"error\":{\"code\":-32603,\"message\":\"Internal Error\",\"data\":\"Internal JSON-RPC error.\"}}"
}
}
The original error is not useful as a string, and is effectively two layers deep.
Expected behavior
The error object should be informative of the error encountered, if it is coming from the server (instead of, say, a networking error.)