pub struct ToolError {
pub schema_version: u8,
pub kind: ServiceErrorKind,
pub code: String,
pub message: String,
pub retryable: bool,
pub remediation: String,
pub field: Option<String>,
pub bad_value: Option<String>,
pub expected_pattern: Option<String>,
pub reason_kind: Option<String>,
pub available_actions: Vec<&'static str>,
}Expand description
Structured error DTO shared by REST and MCP rendering surfaces.
Fields§
§schema_version: u8Version of the error payload schema.
kind: ServiceErrorKindHigh-level failure category.
code: StringStable machine-readable error code.
message: StringHuman-readable error message.
retryable: boolWhether the caller may retry the operation.
remediation: StringActionable guidance for resolving the error.
field: Option<String>Offending input field, when the error is field-specific.
bad_value: Option<String>The rejected value, when a specific value caused the failure.
expected_pattern: Option<String>Expected pattern the input should have matched.
reason_kind: Option<String>Sub-classification of an execution failure (the underlying kind).
available_actions: Vec<&'static str>Valid action names to suggest to the caller.
Implementations§
Source§impl ToolError
impl ToolError
Sourcepub fn validation(
code: impl Into<String>,
message: impl Into<String>,
remediation: impl Into<String>,
) -> Self
pub fn validation( code: impl Into<String>, message: impl Into<String>, remediation: impl Into<String>, ) -> Self
Builds a Validation-kind error from a code, message, and remediation.
Sourcepub fn from_action_validation(error: &ActionValidationError) -> Self
pub fn from_action_validation(error: &ActionValidationError) -> Self
Builds a validation error from an ActionValidationError, using the
full set of known action names as suggestions.
Sourcepub fn from_action_validation_with_actions(
error: &ActionValidationError,
available_actions: Vec<&'static str>,
) -> Self
pub fn from_action_validation_with_actions( error: &ActionValidationError, available_actions: Vec<&'static str>, ) -> Self
Builds a validation error from an ActionValidationError with an
explicit list of available action names.
Sourcepub fn execution(error: &Error) -> Self
pub fn execution(error: &Error) -> Self
Builds an execution error, classifying the underlying anyhow error
into a ServiceErrorKind and setting retryability accordingly.
Sourcepub fn with_field(self, field: impl Into<String>) -> Self
pub fn with_field(self, field: impl Into<String>) -> Self
Sets the offending input field and returns self.
Sourcepub fn with_bad_value(self, bad_value: impl Into<String>) -> Self
pub fn with_bad_value(self, bad_value: impl Into<String>) -> Self
Sets the rejected value and returns self.
Sourcepub fn with_expected_pattern(self, expected_pattern: impl Into<String>) -> Self
pub fn with_expected_pattern(self, expected_pattern: impl Into<String>) -> Self
Sets the expected input pattern and returns self.
Sourcepub fn with_available_actions(
self,
available_actions: Vec<&'static str>,
) -> Self
pub fn with_available_actions( self, available_actions: Vec<&'static str>, ) -> Self
Sets the list of suggested action names and returns self.
Sourcepub fn http_status_code(&self) -> u16
pub fn http_status_code(&self) -> u16
Returns the HTTP status code for this error’s kind.
Sourcepub fn to_rest_payload(&self) -> Value
pub fn to_rest_payload(&self) -> Value
Renders this error as a REST response JSON payload.
Trait Implementations§
impl Eq for ToolError
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.