Skip to content

Original error object is not available in thrown error #306

Open
@bradjones1

Description

@bradjones1

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions