Skip to main content

IntoToolError

Trait IntoToolError 

Source
pub trait IntoToolError {
    // Required method
    fn tool_err(self, context: impl Display) -> ToolError;
}
Expand description

Convenience trait for converting to ToolError with context.

Provides .tool_err() method for easy error conversion with custom messages.

§Example

use turbomcp_core::response::IntoToolError;

fn process() -> Result<(), ToolError> {
    some_operation()
        .map_err(|e| e.tool_err("Failed to process"))?;
    Ok(())
}

Required Methods§

Source

fn tool_err(self, context: impl Display) -> ToolError

Convert to a ToolError with additional context

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<E> IntoToolError for E
where E: Display,