pub enum ToolError {
NotFound {
name: String,
},
Unavailable {
name: String,
reason: ToolUnavailableReason,
},
InvalidArguments {
name: String,
reason: String,
},
ExecutionFailed {
message: String,
},
ExecutionFailedWithData {
message: String,
data: Value,
},
Timeout {
name: String,
timeout_ms: u64,
},
AccessDenied {
name: String,
},
Other(String),
CallbackPending {
tool_name: String,
args: Value,
},
}Expand description
Error returned by tool dispatch operations.
Variants§
NotFound
The requested tool was not found
The tool exists but is currently unavailable
InvalidArguments
The tool arguments failed validation
ExecutionFailed
The tool execution failed
ExecutionFailedWithData
The tool execution failed with structured error data for protocol surfaces.
Timeout
The tool execution timed out
AccessDenied
Tool access was denied by policy
Other(String)
A generic tool error with a message
CallbackPending
Tool call must be routed externally (callback pending)
This variant signals that a tool call cannot be handled internally and must be routed to an external handler. The payload contains serialized information about the pending tool call.
Implementations§
Source§impl ToolError
impl ToolError
pub fn error_code(&self) -> &'static str
pub fn to_error_payload(&self) -> Value
Sourcepub fn to_transcript_content(&self) -> String
pub fn to_transcript_content(&self) -> String
Render the canonical model-facing transcript text for this typed error.
This is the single render boundary over the typed error: it projects
Self::to_error_payload into the JSON string that appears in the
conversation transcript. It is infallible — serde_json::Value always
renders via its Display impl — so there is no fallback string that
could mask a serialization fault.
pub fn not_found(name: impl Into<String>) -> ToolError
pub fn invalid_arguments( name: impl Into<String>, reason: impl Into<String>, ) -> ToolError
pub fn execution_failed(message: impl Into<String>) -> ToolError
pub fn execution_failed_with_data( message: impl Into<String>, data: Value, ) -> ToolError
pub fn structured_data(&self) -> Option<Value>
pub fn timeout(name: impl Into<String>, timeout_ms: u64) -> ToolError
pub fn access_denied(name: impl Into<String>) -> ToolError
pub fn other(message: impl Into<String>) -> ToolError
Sourcepub fn callback_pending(tool_name: impl Into<String>, args: Value) -> ToolError
pub fn callback_pending(tool_name: impl Into<String>, args: Value) -> ToolError
Create a callback pending error for external tool routing
Sourcepub fn is_callback_pending(&self) -> bool
pub fn is_callback_pending(&self) -> bool
Check if this is a callback pending error
Sourcepub fn as_callback_pending(&self) -> Option<(&str, &Value)>
pub fn as_callback_pending(&self) -> Option<(&str, &Value)>
Extract callback pending info if this is a CallbackPending error
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<ToolError> for DispatchError
impl From<ToolError> for DispatchError
impl StructuralPartialEq for ToolError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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>
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>
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 more