pub struct HandlerError { /* private fields */ }Expand description
The error a ToolHandler returns from its own code.
A handler is only ever called with an already-typed, already-validated input, so it never has to report a schema mismatch. What it reports is a genuine failure of the work it does: a provider rejected the request, a precondition did not hold, and so on. This type carries a human-readable message and an optional underlying source error.
The dispatch layer wraps a returned HandlerError in
ToolError::Handler, tagging it with the tool name.
Implementations§
Source§impl HandlerError
impl HandlerError
Sourcepub fn message(message: impl Into<String>) -> Self
pub fn message(message: impl Into<String>) -> Self
Builds a HandlerError from a message alone, with no underlying source.
Sourcepub fn new(source: impl Into<Box<dyn Error + Send + Sync + 'static>>) -> Self
pub fn new(source: impl Into<Box<dyn Error + Send + Sync + 'static>>) -> Self
Builds a HandlerError that wraps an underlying error as its source.
The message is taken from the source’s Display output, so the wrapped
error’s own text is preserved. Use this to forward a ?-propagated
error out of a handler: some_call().map_err(HandlerError::new)?.
Trait Implementations§
Source§impl Debug for HandlerError
impl Debug for HandlerError
Source§impl Display for HandlerError
impl Display for HandlerError
Source§impl Error for HandlerError
impl Error for HandlerError
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()