pub struct ErrorDetail {
pub kind: ErrorKind,
pub code: ErrorCode,
pub message: String,
pub user_message: String,
pub retry_after_ms: Option<u64>,
pub source: ErrorSource,
}Expand description
Structured failure detail attached to a crate::value::Value::FatalError and to
every EngineEvent::Error. Replaces the previous (message, kind)
shape with a richer envelope so SDKs can decide what to do, users get
actionable text, and developers get structured fields for OTel/logs.
Construction patterns:
- Simple:
ErrorDetail::from_kind(ErrorKind::ScriptError, "div by zero")— pulls a generic code (AKRIBES-E-SCRIPT-ERROR) and the kind’s default user message. - Specific:
ErrorDetail::new(ErrorCode::ProviderRateLimit, "...")— code drives kind + default user_message viaErrorCode::kind. - With retry hint:
.with_retry_after_ms(30_000). - With source:
.with_source(ErrorSource::default().with_task("foo")).
Fields§
§kind: ErrorKind§code: ErrorCode§message: StringDeveloper-facing message — full detail, may include sanitized stack/protocol fragments. Always non-empty.
user_message: StringUser-facing single-paragraph summary + suggested action. Always
non-empty (defaults to ErrorCode::default_user_message).
retry_after_ms: Option<u64>When the provider supplied a Retry-After (or equivalent), the
suggested wait in milliseconds. None when not known.
source: ErrorSourceWhere the error originated. Empty (is_empty()) when no
attribution is available.
Implementations§
Source§impl ErrorDetail
impl ErrorDetail
Sourcepub fn new(code: ErrorCode, message: impl Into<String>) -> Self
pub fn new(code: ErrorCode, message: impl Into<String>) -> Self
Construct from a code + developer message. Kind and user_message are derived from the code.
Sourcepub fn from_kind(kind: ErrorKind, message: impl Into<String>) -> Self
pub fn from_kind(kind: ErrorKind, message: impl Into<String>) -> Self
Construct from an existing kind when no specific code is yet
available. Picks the closest “Other” code for that kind, and for
rate-limit/server messages also extracts a retry_after_ms hint
when the upstream response embedded one.
Sourcepub fn with_user_message(self, msg: impl Into<String>) -> Self
pub fn with_user_message(self, msg: impl Into<String>) -> Self
Override the user-facing message. Use when the default for the code isn’t specific enough (e.g. embedding the offending value).
pub fn with_retry_after_ms(self, ms: u64) -> Self
pub fn with_source(self, source: ErrorSource) -> Self
Sourcepub fn with_task(self, task: impl Into<String>) -> Self
pub fn with_task(self, task: impl Into<String>) -> Self
Convenience: builder-style task attribution.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying as-is may succeed. Pulls from the kind plus
retry_after_ms (an explicit hint always implies retryable).
pub fn suggested_action(&self) -> SuggestedAction
Trait Implementations§
Source§impl Clone for ErrorDetail
impl Clone for ErrorDetail
Source§fn clone(&self) -> ErrorDetail
fn clone(&self) -> ErrorDetail
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 ErrorDetail
impl Debug for ErrorDetail
Source§impl<'de> Deserialize<'de> for ErrorDetail
impl<'de> Deserialize<'de> for ErrorDetail
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ErrorDetail
impl Display for ErrorDetail
Source§impl PartialEq for ErrorDetail
impl PartialEq for ErrorDetail
Source§fn eq(&self, other: &ErrorDetail) -> bool
fn eq(&self, other: &ErrorDetail) -> bool
self and other values to be equal, and is used by ==.