pub struct JsonRpcError {
pub jsonrpc: String,
pub id: RequestId,
pub error: ErrorObject,
}Expand description
JSON-RPC error message
Fields§
§jsonrpc: StringJSON-RPC version (always “2.0”)
id: RequestIdRequest ID for correlation
error: ErrorObjectError information
Implementations§
Source§impl JsonRpcError
impl JsonRpcError
Sourcepub fn new<S: Into<String>>(id: RequestId, code: i32, message: S) -> Self
pub fn new<S: Into<String>>(id: RequestId, code: i32, message: S) -> Self
Create a new JSON-RPC error with the given parameters
§Examples
use prism_mcp_rs::protocol::JsonRpcError;
use serde_json::json;
let error = JsonRpcError::new(
json!("req-123"),
-32601,
"Method not found"
);Sourcepub fn with_data<S: Into<String>>(
id: RequestId,
code: i32,
message: S,
data: Option<Value>,
) -> Self
pub fn with_data<S: Into<String>>( id: RequestId, code: i32, message: S, data: Option<Value>, ) -> Self
Create a new JSON-RPC error with additional data
§Examples
use prism_mcp_rs::protocol::JsonRpcError;
use serde_json::json;
let error = JsonRpcError::with_data(
json!("req-123"),
-32602,
"Invalid params",
Some(json!({"expected": "string", "got": "number"}))
);Sourcepub fn parse_error(id: RequestId) -> Self
pub fn parse_error(id: RequestId) -> Self
Create a “Parse error” response (-32700)
Invalid JSON was received by the server
Sourcepub fn invalid_request(id: RequestId) -> Self
pub fn invalid_request(id: RequestId) -> Self
Create an “Invalid Request” response (-32600)
The JSON sent is not a valid Request object
Sourcepub fn method_not_found(id: RequestId) -> Self
pub fn method_not_found(id: RequestId) -> Self
Create a “Method not found” response (-32601)
The method does not exist or is not available
Sourcepub fn method_not_found_with_name<S: Into<String>>(
id: RequestId,
method: S,
) -> Self
pub fn method_not_found_with_name<S: Into<String>>( id: RequestId, method: S, ) -> Self
Create a “Method not found” response with the method name
Sourcepub fn invalid_params(id: RequestId) -> Self
pub fn invalid_params(id: RequestId) -> Self
Create an “Invalid params” response (-32602)
Invalid method parameter(s)
Sourcepub fn invalid_params_with_message<S: Into<String>>(
id: RequestId,
details: S,
) -> Self
pub fn invalid_params_with_message<S: Into<String>>( id: RequestId, details: S, ) -> Self
Create an “Invalid params” response with details
Sourcepub fn internal_error(id: RequestId) -> Self
pub fn internal_error(id: RequestId) -> Self
Create an “Internal error” response (-32603)
Internal JSON-RPC error
Sourcepub fn internal_error_with_message<S: Into<String>>(
id: RequestId,
details: S,
) -> Self
pub fn internal_error_with_message<S: Into<String>>( id: RequestId, details: S, ) -> Self
Create an “Internal error” response with details
Sourcepub fn tool_not_found<S: Into<String>>(id: RequestId, tool_name: S) -> Self
pub fn tool_not_found<S: Into<String>>(id: RequestId, tool_name: S) -> Self
Create a “Tool not found” error (-32000)
MCP-specific: The requested tool does not exist
Sourcepub fn resource_not_found<S: Into<String>>(id: RequestId, uri: S) -> Self
pub fn resource_not_found<S: Into<String>>(id: RequestId, uri: S) -> Self
Create a “Resource not found” error (-32001)
MCP-specific: The requested resource does not exist
Sourcepub fn prompt_not_found<S: Into<String>>(id: RequestId, prompt_name: S) -> Self
pub fn prompt_not_found<S: Into<String>>(id: RequestId, prompt_name: S) -> Self
Create a “Prompt not found” error (-32002)
MCP-specific: The requested prompt does not exist
Trait Implementations§
Source§impl Clone for JsonRpcError
impl Clone for JsonRpcError
Source§fn clone(&self) -> JsonRpcError
fn clone(&self) -> JsonRpcError
1.0.0 (const: unstable) · 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<JsonRpcError> for JsonRpcMessage
impl From<JsonRpcError> for JsonRpcMessage
Source§fn from(error: JsonRpcError) -> Self
fn from(error: JsonRpcError) -> Self
Source§impl IntoJsonRpcMessage for JsonRpcError
impl IntoJsonRpcMessage for JsonRpcError
fn into_message(self) -> JsonRpcMessage
Source§impl PartialEq for JsonRpcError
impl PartialEq for JsonRpcError
Source§fn eq(&self, other: &JsonRpcError) -> bool
fn eq(&self, other: &JsonRpcError) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for JsonRpcError
impl Serialize for JsonRpcError
impl StructuralPartialEq for JsonRpcError
Source§impl TryFrom<JsonRpcMessage> for JsonRpcError
impl TryFrom<JsonRpcMessage> for JsonRpcError
Auto Trait Implementations§
impl Freeze for JsonRpcError
impl RefUnwindSafe for JsonRpcError
impl Send for JsonRpcError
impl Sync for JsonRpcError
impl Unpin for JsonRpcError
impl UnsafeUnpin for JsonRpcError
impl UnwindSafe for JsonRpcError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].