The Exceptions hierarchy
All exceptions are rooted in the Exception
class.
The RPCError
class derives from it and forms the basis of all tinyrpc exceptions.
Abstract exceptions
These exceptions, most of them will be overridden, define errors concerning the transport and structure of messages.
- class tinyrpc.exc.RPCError
Bases:
Exception
,ABC
Base class for all exceptions thrown by
tinyrpc
.- error_respond()
Converts the error to an error response object.
- Returns:
An error response instance or
None
if the protocol decides to drop the error silently.- Return type:
- class tinyrpc.exc.BadRequestError
Bases:
RPCError
,ABC
Base class for all errors that caused the processing of a request to abort before a request object could be instantiated.
- class tinyrpc.exc.BadReplyError
Bases:
RPCError
,ABC
Base class for all errors that caused processing of a reply to abort before it could be turned in a response object.
- class tinyrpc.exc.InvalidRequestError
Bases:
BadRequestError
,ABC
A request made was malformed (i.e. violated the specification) and could not be parsed.
- class tinyrpc.exc.InvalidReplyError
Bases:
BadReplyError
,ABC
A reply received was malformed (i.e. violated the specification) and could not be parsed into a response.
Protocol exceptions
Each protocol provides its own concrete implementations of these exceptions.
JSON-RPC
- class tinyrpc.protocols.jsonrpc.JSONRPCParseError(*args, **kwargs)
Bases:
FixedErrorMessageMixin
,InvalidRequestError
The request cannot be decoded or is malformed.
- class tinyrpc.protocols.jsonrpc.JSONRPCInvalidRequestError(*args, **kwargs)
Bases:
FixedErrorMessageMixin
,InvalidRequestError
The request contents are not valid for JSON RPC 2.0
- class tinyrpc.protocols.jsonrpc.JSONRPCMethodNotFoundError(*args, **kwargs)
Bases:
FixedErrorMessageMixin
,MethodNotFoundError
The requested method name is not found in the registry.
- class tinyrpc.protocols.jsonrpc.JSONRPCInvalidParamsError(*args, **kwargs)
Bases:
FixedErrorMessageMixin
,InvalidRequestError
The provided parameters are not appropriate for the function called.
- class tinyrpc.protocols.jsonrpc.JSONRPCInternalError(*args, **kwargs)
Bases:
FixedErrorMessageMixin
,InvalidRequestError
Unspecified error, not in the called function.
- class tinyrpc.protocols.jsonrpc.JSONRPCServerError(*args, **kwargs)
Bases:
FixedErrorMessageMixin
,InvalidRequestError
Unspecified error, this message originates from the called function.
This last exception is a client side exception designed to represent the server side error in the client.
- class tinyrpc.protocols.jsonrpc.JSONRPCError(error: JSONRPCErrorResponse | Dict[str, Any])
Bases:
FixedErrorMessageMixin
,RPCError
Reconstructs (to some extend) the server-side exception.
The client creates this exception by providing it with the
error
attribute of the JSON error response object returned by the server.- Parameters:
error (dict) –
This dict contains the error specification:
code (int): the numeric error code.
message (str): the error description.
data (any): if present, the data attribute of the error
MSGPACK-RPC
- class tinyrpc.protocols.msgpackrpc.MSGPACKRPCParseError(*args, **kwargs)
- class tinyrpc.protocols.msgpackrpc.MSGPACKRPCInvalidRequestError(*args, **kwargs)
- class tinyrpc.protocols.msgpackrpc.MSGPACKRPCMethodNotFoundError(*args, **kwargs)
- class tinyrpc.protocols.msgpackrpc.MSGPACKRPCInvalidParamsError(*args, **kwargs)
- class tinyrpc.protocols.msgpackrpc.MSGPACKRPCInternalError(*args, **kwargs)
- class tinyrpc.protocols.msgpackrpc.MSGPACKRPCServerError(*args, **kwargs)
This last exception is a client side exception designed to represent the server side error in the client.
- class tinyrpc.protocols.msgpackrpc.MSGPACKRPCError(error: MSGPACKRPCErrorResponse | Tuple[int, str])
Bases:
FixedErrorMessageMixin
,RPCError
Reconstructs (to some extend) the server-side exception.
The client creates this exception by providing it with the
error
attribute of the MSGPACK error response object returned by the server.- Parameters:
error – This tuple contains the error specification: the numeric error code and the error description.