Skip to main content

AdkError

Struct AdkError 

Source
pub struct AdkError {
    pub component: ErrorComponent,
    pub category: ErrorCategory,
    pub code: &'static str,
    pub message: String,
    pub retry: RetryHint,
    pub details: Box<ErrorDetails>,
    /* private fields */
}
Expand description

Unified structured error type for all ADK-Rust operations.

§Migration from enum syntax

Before (0.4.x enum):

// Construction
Err(AdkError::Model("rate limited".into()))
// Matching
matches!(err, AdkError::Model(_))

After (0.5.x struct):

use adk_core::{AdkError, ErrorComponent, ErrorCategory};

// Structured construction
let err = AdkError::new(
    ErrorComponent::Model,
    ErrorCategory::RateLimited,
    "model.openai.rate_limited",
    "rate limited",
);

// Backward-compat construction (for migration)
let err = AdkError::model("rate limited");

// Checking
assert!(err.is_model());
assert!(err.is_retryable()); // reads retry.should_retry

Fields§

§component: ErrorComponent§category: ErrorCategory§code: &'static str§message: String§retry: RetryHint§details: Box<ErrorDetails>

Implementations§

Source§

impl AdkError

Source

pub fn new( component: ErrorComponent, category: ErrorCategory, code: &'static str, message: impl Into<String>, ) -> Self

Source

pub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self

Source

pub fn with_retry(self, retry: RetryHint) -> Self

Source

pub fn with_details(self, details: ErrorDetails) -> Self

Source

pub fn with_upstream_status(self, status_code: u16) -> Self

Source

pub fn with_request_id(self, request_id: impl Into<String>) -> Self

Source

pub fn with_provider(self, provider: impl Into<String>) -> Self

Source§

impl AdkError

Source

pub fn not_found( component: ErrorComponent, code: &'static str, message: impl Into<String>, ) -> Self

Source

pub fn rate_limited( component: ErrorComponent, code: &'static str, message: impl Into<String>, ) -> Self

Source

pub fn unauthorized( component: ErrorComponent, code: &'static str, message: impl Into<String>, ) -> Self

Source

pub fn internal( component: ErrorComponent, code: &'static str, message: impl Into<String>, ) -> Self

Source

pub fn timeout( component: ErrorComponent, code: &'static str, message: impl Into<String>, ) -> Self

Source

pub fn unavailable( component: ErrorComponent, code: &'static str, message: impl Into<String>, ) -> Self

Source§

impl AdkError

Source

pub fn agent(message: impl Into<String>) -> Self

Source

pub fn model(message: impl Into<String>) -> Self

Source

pub fn tool(message: impl Into<String>) -> Self

Source

pub fn session(message: impl Into<String>) -> Self

Source

pub fn memory(message: impl Into<String>) -> Self

Source

pub fn config(message: impl Into<String>) -> Self

Source

pub fn artifact(message: impl Into<String>) -> Self

Source§

impl AdkError

Source

pub fn is_agent(&self) -> bool

Source

pub fn is_model(&self) -> bool

Source

pub fn is_tool(&self) -> bool

Source

pub fn is_session(&self) -> bool

Source

pub fn is_artifact(&self) -> bool

Source

pub fn is_memory(&self) -> bool

Source

pub fn is_config(&self) -> bool

Source§

impl AdkError

Source

pub fn is_retryable(&self) -> bool

Source

pub fn is_not_found(&self) -> bool

Source

pub fn is_unauthorized(&self) -> bool

Source

pub fn is_rate_limited(&self) -> bool

Source

pub fn is_timeout(&self) -> bool

Source§

impl AdkError

Source

pub fn http_status_code(&self) -> u16

Source§

impl AdkError

Source

pub fn to_problem_json(&self) -> Value

Trait Implementations§

Source§

impl Debug for AdkError

Source§

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

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

impl Display for AdkError

Source§

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

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

impl Error for AdkError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<IdentityError> for AdkError

Source§

fn from(err: IdentityError) -> Self

Converts to this type from the input type.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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