class ACP::JsonRpcError

Overview

Represents a JSON-RPC 2.0 error returned by the agent. See: https://www.jsonrpc.org/specification#error_object

Defined in:

acp/errors.cr

Constant Summary

AUTH_REQUIRED = -32000

Authentication is required before this operation can be performed.

INTERNAL_ERROR = -32603
INVALID_PARAMS = -32602
INVALID_REQUEST = -32600
METHOD_NOT_FOUND = -32601
PARSE_ERROR = -32700

Standard JSON-RPC 2.0 error codes

RESOURCE_NOT_FOUND = -32002

A given resource, such as a file, was not found.

SERVER_ERROR_END = -32000
SERVER_ERROR_START = -32099

JSON-RPC 2.0 reserved range for server errors: -32000 to -32099

Constructors

Instance Method Summary

Constructor Detail

def self.from_json_any(obj : JSON::Any) : JsonRpcError #

Constructs a JsonRpcError from a raw JSON::Any error object. Expects the object to have "code" (int) and "message" (string) keys, with an optional "data" key.


[View source]
def self.new(code : Int32, message : String, data : JSON::Any | Nil = nil) #

[View source]

Instance Method Detail

def auth_required? : Bool #

Returns true if this is an ACP authentication-required error.


[View source]
def code : Int32 #

The integer error code.


[View source]
def data : JSON::Any | Nil #

Optional structured data attached to the error.


[View source]
def internal_error? : Bool #

Returns true if this is a standard JSON-RPC internal error.


[View source]
def invalid_params? : Bool #

Returns true if this is a standard JSON-RPC invalid params error.


[View source]
def invalid_request? : Bool #

Returns true if this is a standard JSON-RPC invalid request error.


[View source]
def method_not_found? : Bool #

Returns true if this is a standard JSON-RPC method-not-found error.


[View source]
def parse_error? : Bool #

Returns true if this is a standard JSON-RPC parse error.


[View source]
def resource_not_found? : Bool #

Returns true if this is an ACP resource-not-found error.


[View source]
def server_error? : Bool #

Returns true if the error code falls in the server-defined range.


[View source]
def to_s(io : IO) : Nil #

Builds a human-readable representation including the code.


[View source]