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,ABCBase class for all exceptions thrown by
tinyrpc.- error_respond()
Converts the error to an error response object.
- Returns:
An error response instance or
Noneif the protocol decides to drop the error silently.- Return type:
- class tinyrpc.exc.BadRequestError
Bases:
RPCError,ABCBase 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,ABCBase 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,ABCA request made was malformed (i.e. violated the specification) and could not be parsed.
- class tinyrpc.exc.InvalidReplyError
Bases:
BadReplyError,ABCA 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,InvalidRequestErrorThe request cannot be decoded or is malformed.
- class tinyrpc.protocols.jsonrpc.JSONRPCInvalidRequestError(*args, **kwargs)
Bases:
FixedErrorMessageMixin,InvalidRequestErrorThe request contents are not valid for JSON RPC 2.0
- class tinyrpc.protocols.jsonrpc.JSONRPCMethodNotFoundError(*args, **kwargs)
Bases:
FixedErrorMessageMixin,MethodNotFoundErrorThe requested method name is not found in the registry.
- class tinyrpc.protocols.jsonrpc.JSONRPCInvalidParamsError(*args, **kwargs)
Bases:
FixedErrorMessageMixin,InvalidRequestErrorThe provided parameters are not appropriate for the function called.
- class tinyrpc.protocols.jsonrpc.JSONRPCInternalError(*args, **kwargs)
Bases:
FixedErrorMessageMixin,InvalidRequestErrorUnspecified error, not in the called function.
- class tinyrpc.protocols.jsonrpc.JSONRPCServerError(*args, **kwargs)
Bases:
FixedErrorMessageMixin,InvalidRequestErrorUnspecified 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,RPCErrorReconstructs (to some extend) the server-side exception.
The client creates this exception by providing it with the
errorattribute 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,RPCErrorReconstructs (to some extend) the server-side exception.
The client creates this exception by providing it with the
errorattribute 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.