pub enum ToolError {
NotFound(String),
InvalidArgs {
tool: String,
message: String,
},
Unavailable {
tool: String,
reason: String,
},
Timeout {
tool: String,
seconds: u64,
},
PermissionDenied(String),
ExecutionFailed {
tool: String,
message: String,
},
CapabilityDenied {
tool: String,
code: String,
message: String,
suppression_key: Option<String>,
suggested_tool: Option<String>,
suggested_action: Option<String>,
},
Other(String),
}Expand description
Tool-specific errors with retry strategy metadata.
These are converted to JSON and sent back to the LLM so it can self-correct (e.g. fix a bad path, retry with different args).
Variants§
NotFound(String)
InvalidArgs
Timeout
PermissionDenied(String)
ExecutionFailed
CapabilityDenied
Fields
Other(String)
Implementations§
Source§impl ToolError
impl ToolError
pub fn capability_denied( tool: impl Into<String>, code: impl Into<String>, message: impl Into<String>, ) -> Self
pub fn with_suppression_key(self, suppression_key: impl Into<String>) -> Self
pub fn with_suggested_tool(self, suggested_tool: impl Into<String>) -> Self
pub fn with_suggested_action(self, suggested_action: impl Into<String>) -> Self
pub fn to_llm_payload(&self) -> ToolErrorResponse
Sourcepub fn to_llm_response(&self) -> String
pub fn to_llm_response(&self) -> String
Convert to a JSON string suitable for the LLM to parse.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether the LLM should retry with different parameters.
pub fn should_suppress_retry(&self) -> bool
pub fn category(&self) -> &'static str
pub fn code(&self) -> &str
pub fn tool_name(&self) -> Option<&str>
pub fn suggested_tool(&self) -> Option<&str>
pub fn suppression_key(&self) -> Option<String>
pub fn suggested_action(&self) -> Option<&str>
Trait Implementations§
Source§impl Error for ToolError
impl Error for ToolError
1.30.0 · 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 Freeze for ToolError
impl RefUnwindSafe for ToolError
impl Send for ToolError
impl Sync for ToolError
impl Unpin for ToolError
impl UnsafeUnpin for ToolError
impl UnwindSafe 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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.
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.