A collection of objects for use in JSON-RPC 2.0 implementations.
pip install jsonrpc2-objects
poetry add jsonrpc2-objects
Available in objects
are the following:
Object | Description |
---|---|
RequestObjectParams | Request with params |
RequestObject | Request without params |
NotificationObjectParams | Notification with params |
NotificationObject | Notification without params |
ErrorResponseObject | Response with result |
ResultResponseObject | Response with error |
Python exceptions are available for each JSON-RPC 2.0 error. Each error
extends JSONRPCError
.
Example use with a client implementing these errors:
from jsonrpcobjects.errors import JSONRPCError, MethodNotFound
try:
client.example_method(params)
except MethodNotFound:
print("Handle method not found")
except JSONRPCError:
print("Handle any JSON RPC error.")