rpc.error
import rpc
Everything here is re-exported by
rpc, soimport rpcis enough and the names are called asrpc.*. Importingrpc.erroron its own works too and reaches the same definitions.
The error codes JSON-RPC defines and the errors rpc raises, kept in a
module of their own so every other part of rpc can use them.
Re-exported by rpc.
Constants
PARSE_ERROR
rpc.PARSE_ERROR
The code for a message that is not valid JSON, -32700.
INVALID_REQUEST
rpc.INVALID_REQUEST
The code for valid JSON that is not a valid JSON-RPC message, -32600.
METHOD_NOT_FOUND
rpc.METHOD_NOT_FOUND
The code for a request naming a method the other side does not have,
-32601.
INVALID_PARAMS
rpc.INVALID_PARAMS
The code for a request whose parameters the method cannot take,
-32602.
INTERNAL_ERROR
rpc.INTERNAL_ERROR
The code for a request that failed while it was being handled, -32603.
SERVER_ERROR_MIN
rpc.SERVER_ERROR_MIN
The lowest code JSON-RPC sets aside for errors a server defines itself,
-32099. The range runs up to SERVER_ERROR_MAX.
SERVER_ERROR_MAX
rpc.SERVER_ERROR_MAX
The highest code JSON-RPC sets aside for errors a server defines itself,
-32000.
Classes
RpcError
class rpc.RpcError < Error
A JSON-RPC error: what a request failed with, on either side of a connection.
Raised from a request handler, it answers the request: its code,
message and data go back to the caller as they are.
Endpoint.request() raises one when the other side answers a request
with an error.
JSON-RPC reserves the codes from -32768 to -32000 for itself; the
constants in this module name the ones it defines. An application’s own
errors take any code outside that range.
import rpc
var error = rpc.RpcError(rpc.INVALID_PARAMS, 'a name is required', { field: 'name' })
echo error.code # -32602
echo error.to_dict() # {code: -32602, message: a name is required, data: {field: name}}
Constructor
rpc.RpcError(code: int, message: string, data)
Returns a new RpcError.
Parameters
code(int) — The error’s code.message(string) — A short description of what went wrong.data(any) — Anything more the other side may need, sent along with the error. Defaultnil, which sends nothing.
RpcError.to_dict()
rpc.RpcError.to_dict() -> dict
The error as JSON-RPC sends it: { code, message }, and data as well
when the error carries any.
Returns dict
RpcFramingError
class rpc.RpcFramingError < Error
Raised when the framing of a stream cannot be read: a header block that is not ASCII, a header without a length, a length that is not a whole number, a header or message larger than the framing allows, or a charset other than UTF-8. Nothing after it in the stream can be read.
Constructor
rpc.RpcFramingError(message: string)
Returns a new RpcFramingError.
Parameters
message(string) — What was wrong with the stream.
RpcClosedError
class rpc.RpcClosedError < Error
Raised by Endpoint.request() when the connection ends before the
answer arrives, and by sending on an endpoint that has been closed.
Constructor
rpc.RpcClosedError(message: string)
Returns a new RpcClosedError.
Parameters
message(string) — What could not be done.
RpcTimeoutError
class rpc.RpcTimeoutError < Error
Raised by Endpoint.request() when its timeout runs out before the
answer arrives.
Constructor
rpc.RpcTimeoutError(message: string)
Returns a new RpcTimeoutError.
Parameters
message(string) — What timed out.
RpcHttpError
class rpc.RpcHttpError < Error
Raised by an HttpClient when the server
answers with an HTTP status that carries no JSON-RPC answer: anything
other than 200, or 202 and 204 for a message that needs no answer,
unless the body is a JSON-RPC answer all the same.
Constructor
rpc.RpcHttpError(status: int, message: string, body: string)
Returns a new RpcHttpError.
Parameters
status(int) — The HTTP status the server answered with.message(string) — What went wrong.body(string) — The body the server sent with it, as text;''for none.
2026, Richard Ore and Zuri contributors