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
Core traits and types.
Always available regardless of feature flags. Includes:
Agent- The fundamental trait for all agentsTool/Toolset- For extending agents with capabilitiesSession/State- For managing conversation contextEvent- For streaming agent responsesAdkError/Result- Unified error handling 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",
);
assert!(err.is_retryable()); // RateLimited → should_retry = true
// Backward-compat construction (for migration)
let err = AdkError::model("rate limited");
assert!(err.is_model());Fields§
§component: ErrorComponentThe subsystem that produced the error.
category: ErrorCategoryThe kind of failure.
code: &'static strMachine-readable error code (e.g., “model.openai.rate_limited”).
message: StringHuman-readable error message.
retry: RetryHintRetry guidance for this error.
details: Box<ErrorDetails>Additional structured metadata.
Implementations§
Source§impl AdkError
impl AdkError
Sourcepub fn new(
component: ErrorComponent,
category: ErrorCategory,
code: &'static str,
message: impl Into<String>,
) -> AdkError
Available on crate feature tools only.
pub fn new( component: ErrorComponent, category: ErrorCategory, code: &'static str, message: impl Into<String>, ) -> AdkError
tools only.Creates a new AdkError with the given component, category, code, and message.
Sourcepub fn with_source(self, source: impl Error + Send + Sync + 'static) -> AdkError
Available on crate feature tools only.
pub fn with_source(self, source: impl Error + Send + Sync + 'static) -> AdkError
tools only.Attaches a source error for error chaining.
Sourcepub fn with_retry(self, retry: RetryHint) -> AdkError
Available on crate feature tools only.
pub fn with_retry(self, retry: RetryHint) -> AdkError
tools only.Overrides the default retry hint.
Sourcepub fn with_details(self, details: ErrorDetails) -> AdkError
Available on crate feature tools only.
pub fn with_details(self, details: ErrorDetails) -> AdkError
tools only.Replaces the error details.
Sourcepub fn with_upstream_status(self, status_code: u16) -> AdkError
Available on crate feature tools only.
pub fn with_upstream_status(self, status_code: u16) -> AdkError
tools only.Sets the upstream HTTP status code in details.
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> AdkError
Available on crate feature tools only.
pub fn with_request_id(self, request_id: impl Into<String>) -> AdkError
tools only.Sets the upstream request ID in details.
Sourcepub fn with_provider(self, provider: impl Into<String>) -> AdkError
Available on crate feature tools only.
pub fn with_provider(self, provider: impl Into<String>) -> AdkError
tools only.Sets the provider name in details.
Source§impl AdkError
impl AdkError
Sourcepub fn not_found(
component: ErrorComponent,
code: &'static str,
message: impl Into<String>,
) -> AdkError
Available on crate feature tools only.
pub fn not_found( component: ErrorComponent, code: &'static str, message: impl Into<String>, ) -> AdkError
tools only.Creates a NotFound error for the given component.
Sourcepub fn rate_limited(
component: ErrorComponent,
code: &'static str,
message: impl Into<String>,
) -> AdkError
Available on crate feature tools only.
pub fn rate_limited( component: ErrorComponent, code: &'static str, message: impl Into<String>, ) -> AdkError
tools only.Creates a RateLimited error for the given component.
Available on crate feature tools only.
tools only.Creates an Unauthorized error for the given component.
Sourcepub fn internal(
component: ErrorComponent,
code: &'static str,
message: impl Into<String>,
) -> AdkError
Available on crate feature tools only.
pub fn internal( component: ErrorComponent, code: &'static str, message: impl Into<String>, ) -> AdkError
tools only.Creates an Internal error for the given component.
Sourcepub fn timeout(
component: ErrorComponent,
code: &'static str,
message: impl Into<String>,
) -> AdkError
Available on crate feature tools only.
pub fn timeout( component: ErrorComponent, code: &'static str, message: impl Into<String>, ) -> AdkError
tools only.Creates a Timeout error for the given component.
Available on crate feature tools only.
tools only.Creates an Unavailable error for the given component.
Source§impl AdkError
impl AdkError
Sourcepub fn agent(message: impl Into<String>) -> AdkError
Available on crate feature tools only.
pub fn agent(message: impl Into<String>) -> AdkError
tools only.Legacy convenience constructor for agent errors.
Sourcepub fn model(message: impl Into<String>) -> AdkError
Available on crate feature tools only.
pub fn model(message: impl Into<String>) -> AdkError
tools only.Legacy convenience constructor for model errors.
Sourcepub fn tool(message: impl Into<String>) -> AdkError
Available on crate feature tools only.
pub fn tool(message: impl Into<String>) -> AdkError
tools only.Legacy convenience constructor for tool errors.
Sourcepub fn session(message: impl Into<String>) -> AdkError
Available on crate feature tools only.
pub fn session(message: impl Into<String>) -> AdkError
tools only.Legacy convenience constructor for session errors.
Sourcepub fn memory(message: impl Into<String>) -> AdkError
Available on crate feature tools only.
pub fn memory(message: impl Into<String>) -> AdkError
tools only.Legacy convenience constructor for memory errors.
Source§impl AdkError
impl AdkError
Sourcepub fn is_agent(&self) -> bool
Available on crate feature tools only.
pub fn is_agent(&self) -> bool
tools only.Returns true if this error originated in agent logic.
Sourcepub fn is_model(&self) -> bool
Available on crate feature tools only.
pub fn is_model(&self) -> bool
tools only.Returns true if this error originated in model interaction.
Sourcepub fn is_tool(&self) -> bool
Available on crate feature tools only.
pub fn is_tool(&self) -> bool
tools only.Returns true if this error originated in tool execution.
Sourcepub fn is_session(&self) -> bool
Available on crate feature tools only.
pub fn is_session(&self) -> bool
tools only.Returns true if this error originated in session management.
Sourcepub fn is_artifact(&self) -> bool
Available on crate feature tools only.
pub fn is_artifact(&self) -> bool
tools only.Returns true if this error originated in artifact storage.
Source§impl AdkError
impl AdkError
Sourcepub fn is_retryable(&self) -> bool
Available on crate feature tools only.
pub fn is_retryable(&self) -> bool
tools only.Returns true if this error should be retried.
Sourcepub fn is_not_found(&self) -> bool
Available on crate feature tools only.
pub fn is_not_found(&self) -> bool
tools only.Returns true if this is a not-found error.
Available on crate feature tools only.
tools only.Returns true if this is an unauthorized error.
Sourcepub fn is_rate_limited(&self) -> bool
Available on crate feature tools only.
pub fn is_rate_limited(&self) -> bool
tools only.Returns true if this is a rate-limited error.
Sourcepub fn is_timeout(&self) -> bool
Available on crate feature tools only.
pub fn is_timeout(&self) -> bool
tools only.Returns true if this is a timeout error.
Trait Implementations§
Source§impl Error for AdkError
impl Error for AdkError
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()
Source§impl From<AnthropicApiError> for AdkError
impl From<AnthropicApiError> for AdkError
Source§fn from(err: AnthropicApiError) -> AdkError
fn from(err: AnthropicApiError) -> AdkError
Source§impl From<ComputerUseError> for AdkError
impl From<ComputerUseError> for AdkError
Source§fn from(error: ComputerUseError) -> AdkError
fn from(error: ComputerUseError) -> AdkError
Source§impl From<ConversionError> for AdkError
impl From<ConversionError> for AdkError
Source§fn from(err: ConversionError) -> AdkError
fn from(err: ConversionError) -> AdkError
Source§impl From<ExecutionError> for AdkError
impl From<ExecutionError> for AdkError
Source§fn from(err: ExecutionError) -> AdkError
fn from(err: ExecutionError) -> AdkError
Source§impl From<GraphError> for AdkError
impl From<GraphError> for AdkError
Source§fn from(err: GraphError) -> AdkError
fn from(err: GraphError) -> AdkError
Source§impl From<GuardrailError> for AdkError
impl From<GuardrailError> for AdkError
Source§fn from(err: GuardrailError) -> AdkError
fn from(err: GuardrailError) -> AdkError
Source§impl From<IdentityError> for AdkError
impl From<IdentityError> for AdkError
Source§fn from(err: IdentityError) -> AdkError
fn from(err: IdentityError) -> AdkError
Source§impl From<PaymentsAuthError> for AdkError
impl From<PaymentsAuthError> for AdkError
Source§fn from(value: PaymentsAuthError) -> AdkError
fn from(value: PaymentsAuthError) -> AdkError
Source§impl From<PaymentsKernelError> for AdkError
impl From<PaymentsKernelError> for AdkError
Source§fn from(value: PaymentsKernelError) -> AdkError
fn from(value: PaymentsKernelError) -> AdkError
Source§impl From<SandboxError> for AdkError
impl From<SandboxError> for AdkError
Source§fn from(err: SandboxError) -> AdkError
fn from(err: SandboxError) -> AdkError
Source§fn from(err: SharedStateError) -> AdkError
fn from(err: SharedStateError) -> AdkError
Source§impl From<SkillError> for AdkError
impl From<SkillError> for AdkError
Source§fn from(err: SkillError) -> AdkError
fn from(err: SkillError) -> AdkError
Auto Trait Implementations§
impl !RefUnwindSafe for AdkError
impl !UnwindSafe for AdkError
impl Freeze for AdkError
impl Send for AdkError
impl Sync for AdkError
impl Unpin for AdkError
impl UnsafeUnpin for AdkError
Blanket Implementations§
Source§impl<T> AsErrorSource for Twhere
T: Error + 'static,
impl<T> AsErrorSource for Twhere
T: Error + 'static,
Source§fn as_error_source(&self) -> &(dyn Error + 'static)
fn as_error_source(&self) -> &(dyn Error + 'static)
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more