pub struct ToolExecutionError { /* private fields */ }Expand description
One public envelope for every tool execution failure.
It carries normalized policy fields, separate operator-facing diagnostics
and model-visible output, and an optional concrete source that can be
downcast. Explicit constructors use the diagnostic message as model-visible
output so deliberately authored validation failures remain actionable.
Self::from_error instead treats an arbitrary source as operator-only and
exposes safe kind-level feedback. Use Self::with_model_feedback or
Self::with_model_output to provide a purpose-built presentation.
Implementations§
Source§impl ToolExecutionError
impl ToolExecutionError
Sourcepub fn report(&self) -> ErrorReport
pub fn report(&self) -> ErrorReport
The wire form of this error.
Source§impl ToolExecutionError
impl ToolExecutionError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether the tool may reasonably be re-run: the explicit override when
one was set, else the kind’s own default
(ToolErrorKind::default_retryable); a kind that leaves it to the
tool (None) is not retryable on the wire.
Source§impl ToolExecutionError
impl ToolExecutionError
Sourcepub fn invalid_args(message: impl Into<String>) -> ToolExecutionError
pub fn invalid_args(message: impl Into<String>) -> ToolExecutionError
Invalid arguments.
Sourcepub fn timeout(message: impl Into<String>) -> ToolExecutionError
pub fn timeout(message: impl Into<String>) -> ToolExecutionError
Timeout.
Sourcepub fn cancelled(message: impl Into<String>) -> ToolExecutionError
pub fn cancelled(message: impl Into<String>) -> ToolExecutionError
Cancellation.
Sourcepub fn not_found(message: impl Into<String>) -> ToolExecutionError
pub fn not_found(message: impl Into<String>) -> ToolExecutionError
Missing tool or resource.
Sourcepub fn permission_denied(message: impl Into<String>) -> ToolExecutionError
pub fn permission_denied(message: impl Into<String>) -> ToolExecutionError
An authorization or permission failure.
This is an ordinary execution error. Use Self::refused when the tool
intentionally declines the operation so hooks and telemetry can preserve
the refusal as a distinct disposition.
Sourcepub fn rate_limited(message: impl Into<String>) -> ToolExecutionError
pub fn rate_limited(message: impl Into<String>) -> ToolExecutionError
Rate limit.
Sourcepub fn provider(message: impl Into<String>) -> ToolExecutionError
pub fn provider(message: impl Into<String>) -> ToolExecutionError
Upstream provider failure.
Sourcepub fn network(message: impl Into<String>) -> ToolExecutionError
pub fn network(message: impl Into<String>) -> ToolExecutionError
Network failure.
Sourcepub fn other(message: impl Into<String>) -> ToolExecutionError
pub fn other(message: impl Into<String>) -> ToolExecutionError
Catch-all failure.
Source§impl ToolExecutionError
impl ToolExecutionError
Sourcepub fn new(
kind: ToolErrorKind,
message: impl Into<String>,
) -> ToolExecutionError
pub fn new( kind: ToolErrorKind, message: impl Into<String>, ) -> ToolExecutionError
Construct an error with an explicit normalized kind.
Sourcepub fn refused(message: impl Into<String>) -> ToolExecutionError
pub fn refused(message: impl Into<String>) -> ToolExecutionError
An intentional, tool-authored refusal.
Refusals use the normalized ToolErrorKind::PermissionDenied kind but
remain distinct from permission failures in ToolResult.
Sourcepub fn from_error<E>(error: E) -> ToolExecutionError
pub fn from_error<E>(error: E) -> ToolExecutionError
Build a safely presented Other error from a concrete source.
The source’s display string remains in Self::message, while the model
sees stable ToolErrorKind::Other feedback. Native targets retain the
downcastable source; WASM drops it. An existing ToolExecutionError
retains its classification and presentation.
Sourcepub fn with_model_feedback(
self,
feedback: impl Into<String>,
) -> ToolExecutionError
pub fn with_model_feedback( self, feedback: impl Into<String>, ) -> ToolExecutionError
Replace the model-visible output with literal text feedback.
Sourcepub fn with_model_output(self, output: ToolOutput) -> ToolExecutionError
pub fn with_model_output(self, output: ToolOutput) -> ToolExecutionError
Replace the model-visible output with canonical JSON or multimodal content.
Sourcepub fn with_retryable(self, retryable: bool) -> ToolExecutionError
pub fn with_retryable(self, retryable: bool) -> ToolExecutionError
Override the retryability hint.
Sourcepub fn with_code(self, code: impl Into<String>) -> ToolExecutionError
pub fn with_code(self, code: impl Into<String>) -> ToolExecutionError
Attach an application/provider code.
Sourcepub fn with_http_status(self, status: u16) -> ToolExecutionError
pub fn with_http_status(self, status: u16) -> ToolExecutionError
Attach an HTTP status.
Sourcepub fn with_source<E>(self, source: E) -> ToolExecutionError
pub fn with_source<E>(self, source: E) -> ToolExecutionError
Preserve a concrete source for later downcasting.
Browser wasm keeps no source (see the field): the call is accepted and the source dropped, so tool code stays target-independent.
Sourcepub const fn kind(&self) -> ToolErrorKind
pub const fn kind(&self) -> ToolErrorKind
Normalized kind.
Sourcepub fn model_feedback(&self) -> Option<&str>
pub fn model_feedback(&self) -> Option<&str>
Literal model feedback, when the presentation is exactly one plain text block.
Use Self::model_output for JSON or multimodal feedback.
Sourcepub fn model_output(&self) -> &ToolOutput
pub fn model_output(&self) -> &ToolOutput
Canonical model-visible presentation for this error.
Sourcepub const fn http_status(&self) -> Option<u16>
pub const fn http_status(&self) -> Option<u16>
HTTP status.
Sourcepub const fn is_refusal(&self) -> bool
pub const fn is_refusal(&self) -> bool
Whether the tool intentionally refused the operation.
Sourcepub fn downcast_ref<E>(&self) -> Option<&E>
pub fn downcast_ref<E>(&self) -> Option<&E>
Downcast the concrete source to E.
Trait Implementations§
Source§impl Clone for ToolExecutionError
impl Clone for ToolExecutionError
Source§fn clone(&self) -> ToolExecutionError
fn clone(&self) -> ToolExecutionError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolExecutionError
impl Debug for ToolExecutionError
Source§impl<'de> Deserialize<'de> for ToolExecutionError
impl<'de> Deserialize<'de> for ToolExecutionError
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolExecutionError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolExecutionError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for ToolExecutionError
impl Display for ToolExecutionError
Source§impl Error for ToolExecutionError
impl Error for ToolExecutionError
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<ErrorReport> for ToolExecutionError
Rebuilds a tool failure from a dispatch report.
impl From<ErrorReport> for ToolExecutionError
Rebuilds a tool failure from a dispatch report.
An ErrorKind::Tool report keeps its tool kind; other kinds map to the
closest ToolErrorKind. Retryability, code, HTTP status, and refusal are
copied, the message is model-visible, and the report is the source().
Source§fn from(report: ErrorReport) -> ToolExecutionError
fn from(report: ErrorReport) -> ToolExecutionError
Source§impl From<ToolContextError> for ToolExecutionError
impl From<ToolContextError> for ToolExecutionError
Source§fn from(error: ToolContextError) -> ToolExecutionError
fn from(error: ToolContextError) -> ToolExecutionError
Source§impl Serialize for ToolExecutionError
impl Serialize for ToolExecutionError
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl !RefUnwindSafe for ToolExecutionError
impl !UnwindSafe for ToolExecutionError
impl Freeze for ToolExecutionError
impl Send for ToolExecutionError
impl Sync for ToolExecutionError
impl Unpin for ToolExecutionError
impl UnsafeUnpin for ToolExecutionError
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<T> ConditionalSend for Twhere
T: Send,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
Source§fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.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.
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
self.