Skip to content

Improve use of JSON-RPC error/exception types. #352

@msgilligan

Description

@msgilligan

Some JSON-RPC servers (notably versions of Bitcoin prior to v28*) do not support JSON-RPC 2.0 correctly and sometimes include HTTP error status codes (other than 200) when a JSON-RPC protocol error happens (e.g. "Method not found") The incorrect behavior is handled in our current implementation and that has resulted in our API having some issues that should be corrected.

Our JSON-RPC clients currently always return JsonRpcStatusException when a server responds with an HTTP error status -- even when there is a JsonRpcError object available.

I propose that JsonRpcErrorException should be thrown in situations where a method should return a RESULT and an error is in the response. If a JsonRpcResponse is expected then it can be checked for errors with no need for creating or throwing exception. JsonRpcStatusException should be preferred for situations where an actual HTTP status error is returned.

These changes should be made when we start work on the 0.8.0 release as they will change behavior somewhat.

*See Bitcoin Core PR 27101:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions