#[non_exhaustive]pub enum AppError {
Structured {
kind: ErrorKind,
message: String,
detail: Box<ErrorDetail>,
retry_after_secs: Option<u64>,
source: Option<Arc<dyn Error + Send + Sync>>,
},
}Expand description
Application error with structured kind for agents.
§Display
Prints only the technical English message field (lowercase, no trailing
period). Walk std::error::Error::source for the cause chain; do not
duplicate the cause text in message.
§Clone
Source is held in Arc so clones share the cause without re-boxing.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Structured
Structured error used by all library and CLI paths.
Fields
detail: Box<ErrorDetail>Typed catalogue entry this error was built from.
Not optional: the string constructors were removed, so every error
carries its data and therefore both renderings. Boxed to keep
AppError small, since most values are moved around as Result
payloads rather than inspected.
Implementations§
Source§impl AppError
impl AppError
Sourcepub fn of(detail: ErrorDetail) -> Self
pub fn of(detail: ErrorDetail) -> Self
Build an error from the typed catalogue.
This is the constructor product code should use. Both the ErrorKind
and the English wire message are derived from detail, so one failure
can never be reported as two different kinds from two call sites, and it
can never ship without a pt-BR rendering — the renderer’s match has no
_ arm, so a missing translation fails to compile.
Sourcepub fn of_with_source(
detail: ErrorDetail,
source: impl Error + Send + Sync + 'static,
) -> Self
pub fn of_with_source( detail: ErrorDetail, source: impl Error + Send + Sync + 'static, ) -> Self
Self::of with a preserved lower-level cause.
Sourcepub fn localized(&self, locale: Locale) -> String
pub fn localized(&self, locale: Locale) -> String
Render this error in locale, for human stderr.
Always available in both languages: the catalogue is the only way to
build an AppError, and its pt-BR renderer is exhaustive.
Sourcepub fn with_retry_after(self, secs: u64) -> Self
pub fn with_retry_after(self, secs: u64) -> Self
Attach optional Retry-After seconds (HTTP 429 / 503).
Sourcepub fn interrupted() -> Self
pub fn interrupted() -> Self
SIGINT cancel.
Sourcepub fn terminated() -> Self
pub fn terminated() -> Self
SIGTERM cancel.
Sourcepub fn broken_pipe() -> Self
pub fn broken_pipe() -> Self
stdout closed by the reader (pipe consumer exited).
Sourcepub fn detail(&self) -> &ErrorDetail
pub fn detail(&self) -> &ErrorDetail
Typed catalogue entry this error carries.
Lets a caller wrap one failure inside another (suggestions, context) without flattening it to a string and losing the pt-BR rendering.
Sourcepub fn retry_after_secs(&self) -> Option<u64>
pub fn retry_after_secs(&self) -> Option<u64>
Returns optional Retry-After seconds when present.
Sourcepub fn retryable(&self) -> bool
pub fn retryable(&self) -> bool
Whether an agent may retry the same invocation after backoff.
This is the value that reaches error.retryable on the wire. For
filesystem failures it comes from the OS cause captured where the
std::io::Error was still in hand, because ENOSPC and EACCES are
the same ErrorKind and opposite answers.
Sourcepub fn suggestions(&self) -> Option<&[Suggestion]>
pub fn suggestions(&self) -> Option<&[Suggestion]>
Ranked --suggest alternatives carried by this failure, if any.
Only the outermost detail is inspected: the recovery ladder wraps a
not-found in exactly one ErrorDetail::WithSuggestions, and a nested
one would mean two competing lists with no rule for which wins.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Alias of Self::retryable (Rules Rust checklist name is_retryable).
Sourcepub fn is_permanent(&self) -> bool
pub fn is_permanent(&self) -> bool
Permanent for agent auto-retry (complement of Self::is_retryable).
Sourcepub fn retry_kind(&self) -> RetryKind
pub fn retry_kind(&self) -> RetryKind
Detailed retry category (Rules Rust checklist retry_kind).
Sourcepub fn from_http_status(status: u16, body_hint: &str) -> Self
pub fn from_http_status(status: u16, body_hint: &str) -> Self
Map remote HTTP status to a domain error.
body_hint must be a short, non-sensitive context label (e.g. endpoint
name or "retries exhausted"), never a raw response body or credential.
Trait Implementations§
Source§impl Error for AppError
impl Error for AppError
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()