pub struct ErrorData {
pub code: ErrorCode,
pub message: Cow<'static, str>,
pub data: Option<Value>,
}Expand description
Error information for JSON-RPC error responses.
This structure follows the JSON-RPC 2.0 specification for error reporting, providing a standardized way to communicate errors between clients and servers.
Fields§
§code: ErrorCodeThe error type that occurred (using standard JSON-RPC error codes)
message: Cow<'static, str>A short description of the error. The message SHOULD be limited to a concise single sentence.
data: Option<Value>Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
Implementations§
Source§impl ErrorData
impl ErrorData
pub fn new( code: ErrorCode, message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
Sourcepub fn resource_not_found(
message: impl Into<Cow<'static, str>>,
data: Option<Value>,
) -> Self
pub fn resource_not_found( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
Resource-not-found error (-32002). The server upgrades this to INVALID_PARAMS
(-32602) for peers negotiating protocol 2026-07-28 or newer (SEP-2164).
pub fn header_mismatch( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
Sourcepub fn unsupported_protocol_version(
requested: ProtocolVersion,
supported: &[ProtocolVersion],
) -> Self
pub fn unsupported_protocol_version( requested: ProtocolVersion, supported: &[ProtocolVersion], ) -> Self
Create an unsupported-protocol-version error.
Sourcepub fn missing_required_client_capability(required: ClientCapabilities) -> Self
pub fn missing_required_client_capability(required: ClientCapabilities) -> Self
Create a missing-required-capability error.
pub fn parse_error( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
pub fn invalid_request( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
pub fn method_not_found<M: ConstString>() -> Self
pub fn invalid_params( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
pub fn internal_error( message: impl Into<Cow<'static, str>>, data: Option<Value>, ) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ErrorData
impl<'de> Deserialize<'de> for ErrorData
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 Error for ErrorData
impl Error for ErrorData
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl IntoCallToolResult for ErrorData
Available on crate feature server only.
impl IntoCallToolResult for ErrorData
server only.fn into_call_tool_result(self) -> Result<CallToolResponse, ErrorData>
Source§impl JsonSchema for ErrorData
Available on crate feature schemars only.
impl JsonSchema for ErrorData
schemars only.Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more