Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 20 variants Model(ModelError), ContextWindowOverflow(ContextWindowOverflowError), MaxTokens(MaxTokensError), ModelThrottled(ModelThrottledError), ModelNetwork(ModelNetworkError), JsonValidation(JsonValidationError), ToolValidation(ToolValidationError), ToolNotFound(ToolNotFoundError), StructuredOutput(StructuredOutputError), DefaultNotConfigured(DefaultNotConfiguredError), Storage(StorageError), Session(SessionError), SandboxTimeout(SandboxTimeoutError), SandboxAbort(SandboxAbortError), SandboxPathNotFound(SandboxPathNotFoundError), SandboxIsADirectory(SandboxIsADirectoryError), SandboxPermission(SandboxPermissionError), Mcp(McpError), Interrupt(InterruptError), Other(BoxError),
}
Expand description

Every error the SDK returns.

Display and source delegate to the wrapped error, so its message and cause chain are preserved.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Model(ModelError)

A model provider failed (ModelError).

§

ContextWindowOverflow(ContextWindowOverflowError)

The input exceeded the model’s context window (ContextWindowOverflowError).

§

MaxTokens(MaxTokensError)

The model stopped at its output token limit (MaxTokensError).

§

ModelThrottled(ModelThrottledError)

The provider throttled the request (ModelThrottledError).

§

ModelNetwork(ModelNetworkError)

The network connection to the provider failed (ModelNetworkError).

§

JsonValidation(JsonValidationError)

A value could not be serialized to JSON (JsonValidationError).

§

ToolValidation(ToolValidationError)

A tool failed validation during registration (ToolValidationError).

§

ToolNotFound(ToolNotFoundError)

No tool is registered under the requested name (ToolNotFoundError).

§

StructuredOutput(StructuredOutputError)

The model did not produce structured output (StructuredOutputError).

§

DefaultNotConfigured(DefaultNotConfiguredError)

A default was read before one was configured (DefaultNotConfiguredError).

§

Storage(StorageError)

A storage operation failed (StorageError).

§

Session(SessionError)

A session operation failed (SessionError).

§

SandboxTimeout(SandboxTimeoutError)

Sandbox execution timed out (SandboxTimeoutError).

§

SandboxAbort(SandboxAbortError)

Sandbox execution was aborted (SandboxAbortError).

§

SandboxPathNotFound(SandboxPathNotFoundError)

A sandbox path does not exist (SandboxPathNotFoundError).

§

SandboxIsADirectory(SandboxIsADirectoryError)

A sandbox path is a directory (SandboxIsADirectoryError).

§

SandboxPermission(SandboxPermissionError)

A sandbox path is not accessible (SandboxPermissionError).

§

Mcp(McpError)

An MCP client failed (ProtocolError, SdkError or a plain MCP client error).

§

Interrupt(InterruptError)

A hook raised interrupts outside the events that stop for them (InterruptError).

§

Other(BoxError)

Any other failure, such as I/O or JSON decoding.

Implementations§

Source§

impl Error

Source

pub fn other(error: impl Into<BoxError>) -> Self

Wraps any error as Error::Other.

Source

pub fn from_boxed(error: BoxError) -> Self

Recovers the typed error behind a boxed one: a boxed Error is unwrapped and an InterruptError becomes Error::Interrupt; anything else is Error::Other.

Source

pub fn name(&self) -> &'static str

The wrapped error’s type name, for example "ContextWindowOverflowError".

Error::Other reports "Error".

Source

pub fn is_model_error(&self) -> bool

Whether this is a model error: ModelError or one of the more specific model errors.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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<&Error> for RoutingFailure

Source§

fn from(error: &Error) -> Self

Converts to this type from the input type.
Source§

impl From<ContextWindowOverflowError> for Error

Source§

fn from(source: ContextWindowOverflowError) -> Self

Converts to this type from the input type.
Source§

impl From<DefaultNotConfiguredError> for Error

Source§

fn from(source: DefaultNotConfiguredError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for MiddlewareError

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl From<InterruptError> for Error

Source§

fn from(source: InterruptError) -> Self

Converts to this type from the input type.
Source§

impl From<JsonValidationError> for Error

Source§

fn from(source: JsonValidationError) -> Self

Converts to this type from the input type.
Source§

impl From<MaxTokensError> for Error

Source§

fn from(source: MaxTokensError) -> Self

Converts to this type from the input type.
Source§

impl From<McpError> for Error

Source§

fn from(error: McpError) -> Self

Converts to this type from the input type.
Source§

impl From<ModelError> for Error

Source§

fn from(source: ModelError) -> Self

Converts to this type from the input type.
Source§

impl From<ModelNetworkError> for Error

Source§

fn from(source: ModelNetworkError) -> Self

Converts to this type from the input type.
Source§

impl From<ModelThrottledError> for Error

Source§

fn from(source: ModelThrottledError) -> Self

Converts to this type from the input type.
Source§

impl From<SandboxAbortError> for Error

Source§

fn from(source: SandboxAbortError) -> Self

Converts to this type from the input type.
Source§

impl From<SandboxIsADirectoryError> for Error

Source§

fn from(source: SandboxIsADirectoryError) -> Self

Converts to this type from the input type.
Source§

impl From<SandboxPathNotFoundError> for Error

Source§

fn from(source: SandboxPathNotFoundError) -> Self

Converts to this type from the input type.
Source§

impl From<SandboxPermissionError> for Error

Source§

fn from(source: SandboxPermissionError) -> Self

Converts to this type from the input type.
Source§

impl From<SandboxTimeoutError> for Error

Source§

fn from(source: SandboxTimeoutError) -> Self

Converts to this type from the input type.
Source§

impl From<SessionError> for Error

Source§

fn from(source: SessionError) -> Self

Converts to this type from the input type.
Source§

impl From<StorageError> for Error

Source§

fn from(source: StorageError) -> Self

Converts to this type from the input type.
Source§

impl From<StructuredOutputError> for Error

Source§

fn from(source: StructuredOutputError) -> Self

Converts to this type from the input type.
Source§

impl From<ToolNotFoundError> for Error

Source§

fn from(source: ToolNotFoundError) -> Self

Converts to this type from the input type.
Source§

impl From<ToolValidationError> for Error

Source§

fn from(source: ToolValidationError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

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

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

fn to_smolstr(&self) -> SmolStr

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 = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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