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:
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
JsonRpcStatusExceptionwhen a server responds with an HTTP error status -- even when there is aJsonRpcErrorobject available.I propose that
JsonRpcErrorExceptionshould be thrown in situations where a method should return aRESULTand anerroris in the response. If aJsonRpcResponseis expected then it can be checked for errors with no need for creating or throwing exception.JsonRpcStatusExceptionshould 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: