pub struct JsonRpcError {
pub code: i32,
pub message: String,
pub data: Option<HashMap<String, Value>>,
}
Expand description
§JSON-RPC Error
Represents an error in a JSON-RPC response.
§Example
{
"code": -32602,
"message": "Invalid parameters",
"data": {
"details": "The 'id' parameter is required"
}
}
§Standard Error Codes
-32700
: Parse error - Invalid JSON payload-32600
: Invalid Request - Request payload validation error-32601
: Method Not Found - Requested method does not exist-32602
: Invalid Parameters - Invalid method parameters-32603
: Internal Error - Internal JSON-RPC error
§Custom Error Codes
-32001
: Task Not Found - The requested task wasn’t found-32002
: Task Cannot Be Canceled - The task cannot be canceled-32003
: Push Notification Error - Push notification is not supported or error occurred-32004
: Operation Not Supported - The requested operation is not supported
Fields§
§code: i32
§message: String
§data: Option<HashMap<String, Value>>
Implementations§
Source§impl JsonRpcError
impl JsonRpcError
Sourcepub fn parse_error<T: Display>(error: T) -> Self
pub fn parse_error<T: Display>(error: T) -> Self
Creates a parse error (code -32700) Use this for JSON parsing errors or other syntax errors
Sourcepub fn invalid_request<T: Display>(error: T) -> Self
pub fn invalid_request<T: Display>(error: T) -> Self
Creates an invalid request error (code -32600) Use this when the JSON-RPC request doesn’t follow protocol requirements
Sourcepub fn method_not_found<T: Display>(method: T) -> Self
pub fn method_not_found<T: Display>(method: T) -> Self
Creates a method not found error (code -32601) Use this when the requested method does not exist
Sourcepub fn invalid_parameters<T: Display>(error: T) -> Self
pub fn invalid_parameters<T: Display>(error: T) -> Self
Creates an invalid parameters error (code -32602) Use this when method parameters are invalid
Sourcepub fn internal_error<T: Display>(error: T) -> Self
pub fn internal_error<T: Display>(error: T) -> Self
Creates an internal error (code -32603) Use this for general internal JSON-RPC errors
Sourcepub fn serialization<T: Display>(error: T) -> Self
pub fn serialization<T: Display>(error: T) -> Self
Creates a serialization error (code -32603) Use this for errors during JSON serialization
Sourcepub fn task<T: Display>(error: T) -> Self
pub fn task<T: Display>(error: T) -> Self
Creates a task error (code -32603) Use this for general task processing errors
Sourcepub fn task_not_found<T: Display>(task_id: T) -> Self
pub fn task_not_found<T: Display>(task_id: T) -> Self
Creates a task not found error (code -32001) Use this when a requested task is not found
Sourcepub fn task_cannot_be_canceled<T: Display>(task_id: T) -> Self
pub fn task_cannot_be_canceled<T: Display>(task_id: T) -> Self
Creates a task cannot be canceled error (code -32002) Use this when a task cannot be canceled
Sourcepub fn push_notification<T: Display>(error: T) -> Self
pub fn push_notification<T: Display>(error: T) -> Self
Creates a push notification error (code -32003) Use this for push notification errors
Sourcepub fn task_not_cancelable<T: Display>(error: T) -> Self
pub fn task_not_cancelable<T: Display>(error: T) -> Self
Creates a task not cancelable error (code -32002) Use this when a task is in a final state and cannot be canceled
Sourcepub fn unsupported_operation<T: Display>(error: T) -> Self
pub fn unsupported_operation<T: Display>(error: T) -> Self
Creates an unsupported operation error (code -32004) Use this when the requested operation is not supported
Sourcepub fn content_type_not_supported<T: Display>(error: T) -> Self
pub fn content_type_not_supported<T: Display>(error: T) -> Self
Creates a content type not supported error (code -32005) Use this when there’s a mismatch in supported content types
Sourcepub fn operation_not_supported<T: Display>(operation: T) -> Self
pub fn operation_not_supported<T: Display>(operation: T) -> Self
Creates an operation not supported error (code -32004) Use this when a requested operation is not supported
Trait Implementations§
Source§impl Clone for JsonRpcError
impl Clone for JsonRpcError
Source§fn clone(&self) -> JsonRpcError
fn clone(&self) -> JsonRpcError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for JsonRpcError
impl Debug for JsonRpcError
Source§impl<'de> Deserialize<'de> for JsonRpcError
impl<'de> Deserialize<'de> for JsonRpcError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<Error> for JsonRpcError
Convert std::io::Error to JsonRpcError
impl From<Error> for JsonRpcError
Convert std::io::Error to JsonRpcError
Source§impl From<Error> for JsonRpcError
Convert hyper::Error to JsonRpcError
impl From<Error> for JsonRpcError
Convert hyper::Error to JsonRpcError
Source§impl From<Error> for JsonRpcError
Convert ClientError to JsonRpcError
impl From<Error> for JsonRpcError
Convert ClientError to JsonRpcError
Source§fn from(err: ClientError) -> Self
fn from(err: ClientError) -> Self
Source§impl From<Error> for JsonRpcError
impl From<Error> for JsonRpcError
Source§impl From<InvalidUri> for JsonRpcError
Convert InvalidUri to JsonRpcError
impl From<InvalidUri> for JsonRpcError
Convert InvalidUri to JsonRpcError
Source§fn from(err: InvalidUri) -> Self
fn from(err: InvalidUri) -> Self
Source§impl From<JsonRpcError> for Error
Convert JsonRpcError to ServerError
impl From<JsonRpcError> for Error
Convert JsonRpcError to ServerError
Source§fn from(err: JsonRpcError) -> Self
fn from(err: JsonRpcError) -> Self
Source§impl From<JsonRpcError> for Error
Convert JsonRpcError to ClientError
impl From<JsonRpcError> for Error
Convert JsonRpcError to ClientError
Source§fn from(err: JsonRpcError) -> Self
fn from(err: JsonRpcError) -> Self
Source§impl From<PushNotificationError> for JsonRpcError
Convert PushNotificationError to JsonRpcError
impl From<PushNotificationError> for JsonRpcError
Convert PushNotificationError to JsonRpcError
Source§fn from(err: PushNotificationError) -> Self
fn from(err: PushNotificationError) -> Self
Source§impl From<TaskError> for JsonRpcError
Convert TaskError to JsonRpcError for server-side error handling
impl From<TaskError> for JsonRpcError
Convert TaskError to JsonRpcError for server-side error handling
Source§impl From<TaskManagerError> for JsonRpcError
impl From<TaskManagerError> for JsonRpcError
Source§fn from(error: TaskManagerError) -> Self
fn from(error: TaskManagerError) -> Self
Source§impl From<UrlValidationError> for JsonRpcError
Convert UrlValidationError to JsonRpcError
impl From<UrlValidationError> for JsonRpcError
Convert UrlValidationError to JsonRpcError