2023-12-14 08:34:13 +07:00
|
|
|
# json-rpc
|
2024-03-04 09:19:28 +01:00
|
|
|
# Copyright (c) 2019-2024 Status Research & Development GmbH
|
2023-12-14 08:34:13 +07:00
|
|
|
# Licensed under either of
|
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
|
# at your option.
|
|
|
|
|
# This file may not be copied, modified, or distributed except according to
|
|
|
|
|
# those terms.
|
|
|
|
|
|
2024-10-22 21:58:46 +02:00
|
|
|
{.push raises: [], gcsafe.}
|
2024-03-04 09:19:28 +01:00
|
|
|
|
|
|
|
|
import results, json_serialization
|
|
|
|
|
|
2020-06-19 16:33:44 +03:00
|
|
|
type
|
|
|
|
|
JsonRpcError* = object of CatchableError
|
|
|
|
|
## Base type of all nim-json-rpc errors
|
|
|
|
|
|
|
|
|
|
ErrorResponse* = object of JsonRpcError
|
2023-03-01 12:40:16 +02:00
|
|
|
status*: int
|
2020-06-19 16:33:44 +03:00
|
|
|
## raised when the server responded with an error
|
|
|
|
|
|
|
|
|
|
InvalidResponse* = object of JsonRpcError
|
|
|
|
|
## raised when the server response violates the JSON-RPC protocol
|
|
|
|
|
|
2021-11-22 10:09:13 -03:00
|
|
|
FailedHttpResponse* = object of JsonRpcError
|
|
|
|
|
## raised when fail to read the underlying HTTP server response
|
|
|
|
|
|
|
|
|
|
RpcPostError* = object of JsonRpcError
|
|
|
|
|
## raised when the client fails to send the POST request with JSON-RPC
|
|
|
|
|
|
2021-02-15 13:45:51 +01:00
|
|
|
RpcBindError* = object of JsonRpcError
|
|
|
|
|
RpcAddressUnresolvableError* = object of JsonRpcError
|
2021-10-06 10:50:08 +02:00
|
|
|
|
|
|
|
|
InvalidRequest* = object of JsonRpcError
|
2024-03-04 09:19:28 +01:00
|
|
|
## raised when the server recieves an invalid JSON request object
|
2021-10-06 10:50:08 +02:00
|
|
|
code*: int
|
2024-01-03 20:06:53 +07:00
|
|
|
|
|
|
|
|
RequestDecodeError* = object of JsonRpcError
|
|
|
|
|
## raised when fail to decode RequestRx
|
|
|
|
|
|
|
|
|
|
ParamsEncodeError* = object of JsonRpcError
|
|
|
|
|
## raised when fail to encode RequestParamsTx
|
|
|
|
|
|
2024-03-04 09:19:28 +01:00
|
|
|
ApplicationError* = object of JsonRpcError
|
|
|
|
|
## Error to be raised by the application request handlers when the server
|
|
|
|
|
## needs to respond with a custom application error. The error code should
|
|
|
|
|
## be outside the range of -32768 to -32000. A custom JSON data object may
|
|
|
|
|
## be provided.
|
|
|
|
|
code*: int
|
|
|
|
|
message*: string
|
|
|
|
|
data*: results.Opt[JsonString]
|