client-js icon indicating copy to clipboard operation
client-js copied to clipboard

Original error object is not available in thrown error

Open bradjones1 opened this issue 2 years ago • 0 comments

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:

  1. Make a json-rpc request which returns an error.
  2. 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.)

bradjones1 avatar Mar 17 '22 01:03 bradjones1