#[non_exhaustive]pub enum ToolError {
Message {
message: String,
cause: Option<Box<dyn Error + Send + Sync>>,
},
Json {
value: JsonValue,
},
Timeout(Duration),
Cancelled,
}Expand description
Error returned by a tool execution.
Tool errors are not fatal: the core turns them into error-text /
error-json tool results that are fed back to the model. Only
ToolError::Cancelled aborts the whole call.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Message
A textual error.
Fields
Json
A structured error payload.
Timeout(Duration)
The execution exceeded its timeout.
Cancelled
The execution was cancelled.
Implementations§
Source§impl ToolError
impl ToolError
Sourcepub fn from_error(error: impl Error + Send + Sync + 'static) -> Self
pub fn from_error(error: impl Error + Send + Sync + 'static) -> Self
Wraps any error, using its display text as the message.
Sourcepub fn with_cause(self, cause: impl Error + Send + Sync + 'static) -> Self
pub fn with_cause(self, cause: impl Error + Send + Sync + 'static) -> Self
Attaches a cause to a ToolError::Message; other variants are
returned unchanged.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns true for ToolError::Cancelled.
Trait Implementations§
Source§impl Error for ToolError
impl Error for ToolError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for ToolError
impl !UnwindSafe for ToolError
impl Freeze for ToolError
impl Send for ToolError
impl Sync for ToolError
impl Unpin for ToolError
impl UnsafeUnpin for ToolError
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
Mutably borrows from an owned value. Read more