Struct JsonRpcError

Source
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

Source

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

Source

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

Source

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

Source

pub fn invalid_parameters<T: Display>(error: T) -> Self

Creates an invalid parameters error (code -32602) Use this when method parameters are invalid

Source

pub fn internal_error<T: Display>(error: T) -> Self

Creates an internal error (code -32603) Use this for general internal JSON-RPC errors

Source

pub fn serialization<T: Display>(error: T) -> Self

Creates a serialization error (code -32603) Use this for errors during JSON serialization

Source

pub fn task<T: Display>(error: T) -> Self

Creates a task error (code -32603) Use this for general task processing errors

Source

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

Source

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

Source

pub fn push_notification<T: Display>(error: T) -> Self

Creates a push notification error (code -32003) Use this for push notification errors

Source

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

Source

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

Source

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

Source

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

Source§

fn clone(&self) -> JsonRpcError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JsonRpcError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for JsonRpcError

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Error> for JsonRpcError

Convert std::io::Error to JsonRpcError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for JsonRpcError

Convert hyper::Error to JsonRpcError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for JsonRpcError

Convert ClientError to JsonRpcError

Source§

fn from(err: ClientError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for JsonRpcError

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidUri> for JsonRpcError

Convert InvalidUri to JsonRpcError

Source§

fn from(err: InvalidUri) -> Self

Converts to this type from the input type.
Source§

impl From<JsonRpcError> for Error

Convert JsonRpcError to ServerError

Source§

fn from(err: JsonRpcError) -> Self

Converts to this type from the input type.
Source§

impl From<JsonRpcError> for Error

Convert JsonRpcError to ClientError

Source§

fn from(err: JsonRpcError) -> Self

Converts to this type from the input type.
Source§

impl From<PushNotificationError> for JsonRpcError

Convert PushNotificationError to JsonRpcError

Source§

fn from(err: PushNotificationError) -> Self

Converts to this type from the input type.
Source§

impl From<TaskError> for JsonRpcError

Convert TaskError to JsonRpcError for server-side error handling

Source§

fn from(err: TaskError) -> Self

Converts to this type from the input type.
Source§

impl From<TaskManagerError> for JsonRpcError

Source§

fn from(error: TaskManagerError) -> Self

Converts to this type from the input type.
Source§

impl From<UrlValidationError> for JsonRpcError

Convert UrlValidationError to JsonRpcError

Source§

fn from(err: UrlValidationError) -> Self

Converts to this type from the input type.
Source§

impl Serialize for JsonRpcError

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromBase64 for T
where T: for<'de> Deserialize<'de>,

Source§

fn from_base64<Input>(raw: &Input) -> Result<T, Error>
where Input: AsRef<[u8]> + ?Sized,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<C> SignWithKey<String> for C
where C: ToBase64,

Source§

impl<T> ToBase64 for T
where T: Serialize,

Source§

fn to_base64(&self) -> Result<Cow<'_, str>, Error>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T