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>(err: E) -> CallToolErrorwhere
E: Error + 'static,
pub fn new<E>(err: E) -> CallToolErrorwhere
E: Error + 'static,
Constructor to create a new CallToolError from a generic error.
Sourcepub fn unknown_tool(tool_name: impl Into<String>) -> CallToolError
pub fn unknown_tool(tool_name: impl Into<String>) -> CallToolError
Specific constructor to create a CallToolError for an UnknownTool error.
Sourcepub fn invalid_arguments(
tool_name: impl AsRef<str>,
message: Option<String>,
) -> CallToolError
pub fn invalid_arguments( tool_name: impl AsRef<str>, message: Option<String>, ) -> CallToolError
Creates a CallToolError for invalid arguments with optional details.
Sourcepub fn from_message(message: impl Into<String>) -> CallToolError
pub fn from_message(message: impl Into<String>) -> CallToolError
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) -> CallToolResult
fn from(value: CallToolError) -> CallToolResult
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.
Source§fn from(value: CallToolError) -> RpcError
fn from(value: CallToolError) -> RpcError
Auto Trait Implementations§
impl Freeze for CallToolError
impl !RefUnwindSafe for CallToolError
impl !Send for CallToolError
impl !Sync for CallToolError
impl Unpin for CallToolError
impl !UnwindSafe for CallToolError
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.