Skip to main content

ErrorDetail

Struct ErrorDetail 

Source
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 via ErrorCode::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: String

Developer-facing message — full detail, may include sanitized stack/protocol fragments. Always non-empty.

§user_message: String

User-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: ErrorSource

Where the error originated. Empty (is_empty()) when no attribution is available.

Implementations§

Source§

impl ErrorDetail

Source

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.

Source

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.

Source

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).

Source

pub fn with_retry_after_ms(self, ms: u64) -> Self

Source

pub fn with_source(self, source: ErrorSource) -> Self

Source

pub fn with_task(self, task: impl Into<String>) -> Self

Convenience: builder-style task attribution.

Source

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).

Source

pub fn suggested_action(&self) -> SuggestedAction

Trait Implementations§

Source§

impl Clone for ErrorDetail

Source§

fn clone(&self) -> ErrorDetail

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ErrorDetail

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ErrorDetail

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ErrorDetail

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Renders as <wire-code>: <message> so log lines and the legacy “string error” shape stay readable. Use the structured fields directly when constructing JSON wire payloads.

Source§

impl PartialEq for ErrorDetail

Source§

fn eq(&self, other: &ErrorDetail) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ErrorDetail

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ErrorDetail

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,