pub struct CallToolError(pub Box<dyn Error>);Expand description
A specific error type that can hold any kind of error and is used to
encapsulate various error scenarios when a CallToolRequest fails.
Tuple Fields§
§0: Box<dyn Error>Implementations§
Source§impl CallToolError
impl CallToolError
Sourcepub fn new<E: Error + 'static>(err: E) -> Self
pub fn new<E: Error + 'static>(err: E) -> Self
Constructor to create a new CallToolError from a generic error.
Sourcepub fn unknown_tool(tool_name: impl Into<String>) -> Self
pub fn unknown_tool(tool_name: impl Into<String>) -> Self
Specific constructor to create a CallToolError for an UnknownTool error.
Sourcepub fn invalid_arguments(
tool_name: impl AsRef<str>,
message: Option<String>,
) -> Self
pub fn invalid_arguments( tool_name: impl AsRef<str>, message: Option<String>, ) -> Self
Creates a CallToolError for invalid arguments with optional details.
Sourcepub fn from_message(message: impl Into<String>) -> Self
pub fn from_message(message: impl Into<String>) -> Self
Creates a new CallToolError from a string message.
This is useful for generating ad-hoc or one-off errors without defining a custom error type.
Internally, it wraps the string in a lightweight error type that implements the Error trait.
§Examples
let err = rust_mcp_schema::schema_utils::CallToolError::from_message("Something went wrong");
println!("{:?}", err);§Parameters
message: Any type that can be converted into aString(e.g.,&strorString)
§Returns
A CallToolError wrapping a dynamic error created from the provided message.
Trait Implementations§
Source§impl Debug for CallToolError
impl Debug for CallToolError
Source§impl Display for CallToolError
impl Display for CallToolError
Source§impl Error for CallToolError
impl Error for CallToolError
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
Source§impl From<CallToolError> for CallToolResult
Conversion of CallToolError into a CallToolResult with an error.
impl From<CallToolError> for CallToolResult
Conversion of CallToolError into a CallToolResult with an error.
Source§fn from(value: CallToolError) -> Self
fn from(value: CallToolError) -> Self
Source§impl From<CallToolError> for RpcError
Converts a CallToolError into a RpcError.
impl From<CallToolError> for RpcError
Converts a CallToolError into a RpcError.
The conversion creates an internal error variant of RpcError
and attaches the string representation of the original CallToolError as a message.