#[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
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
impl Error
Sourcepub fn other(error: impl Into<BoxError>) -> Self
pub fn other(error: impl Into<BoxError>) -> Self
Wraps any error as Error::Other.
Sourcepub fn from_boxed(error: BoxError) -> Self
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.
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
The wrapped error’s type name, for example "ContextWindowOverflowError".
Error::Other reports "Error".
Sourcepub fn is_model_error(&self) -> bool
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 Error for Error
impl Error for Error
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<&Error> for RoutingFailure
impl From<&Error> for RoutingFailure
Source§impl From<ContextWindowOverflowError> for Error
impl From<ContextWindowOverflowError> for Error
Source§fn from(source: ContextWindowOverflowError) -> Self
fn from(source: ContextWindowOverflowError) -> Self
Source§impl From<DefaultNotConfiguredError> for Error
impl From<DefaultNotConfiguredError> for Error
Source§fn from(source: DefaultNotConfiguredError) -> Self
fn from(source: DefaultNotConfiguredError) -> Self
Source§impl From<Error> for MiddlewareError
impl From<Error> for MiddlewareError
Source§impl From<InterruptError> for Error
impl From<InterruptError> for Error
Source§fn from(source: InterruptError) -> Self
fn from(source: InterruptError) -> Self
Source§impl From<JsonValidationError> for Error
impl From<JsonValidationError> for Error
Source§fn from(source: JsonValidationError) -> Self
fn from(source: JsonValidationError) -> Self
Source§impl From<MaxTokensError> for Error
impl From<MaxTokensError> for Error
Source§fn from(source: MaxTokensError) -> Self
fn from(source: MaxTokensError) -> Self
Source§impl From<ModelError> for Error
impl From<ModelError> for Error
Source§fn from(source: ModelError) -> Self
fn from(source: ModelError) -> Self
Source§impl From<ModelNetworkError> for Error
impl From<ModelNetworkError> for Error
Source§fn from(source: ModelNetworkError) -> Self
fn from(source: ModelNetworkError) -> Self
Source§impl From<ModelThrottledError> for Error
impl From<ModelThrottledError> for Error
Source§fn from(source: ModelThrottledError) -> Self
fn from(source: ModelThrottledError) -> Self
Source§impl From<SandboxAbortError> for Error
impl From<SandboxAbortError> for Error
Source§fn from(source: SandboxAbortError) -> Self
fn from(source: SandboxAbortError) -> Self
Source§impl From<SandboxIsADirectoryError> for Error
impl From<SandboxIsADirectoryError> for Error
Source§fn from(source: SandboxIsADirectoryError) -> Self
fn from(source: SandboxIsADirectoryError) -> Self
Source§impl From<SandboxPathNotFoundError> for Error
impl From<SandboxPathNotFoundError> for Error
Source§fn from(source: SandboxPathNotFoundError) -> Self
fn from(source: SandboxPathNotFoundError) -> Self
Source§impl From<SandboxPermissionError> for Error
impl From<SandboxPermissionError> for Error
Source§fn from(source: SandboxPermissionError) -> Self
fn from(source: SandboxPermissionError) -> Self
Source§impl From<SandboxTimeoutError> for Error
impl From<SandboxTimeoutError> for Error
Source§fn from(source: SandboxTimeoutError) -> Self
fn from(source: SandboxTimeoutError) -> Self
Source§impl From<SessionError> for Error
impl From<SessionError> for Error
Source§fn from(source: SessionError) -> Self
fn from(source: SessionError) -> Self
Source§impl From<StorageError> for Error
impl From<StorageError> for Error
Source§fn from(source: StorageError) -> Self
fn from(source: StorageError) -> Self
Source§impl From<StructuredOutputError> for Error
impl From<StructuredOutputError> for Error
Source§fn from(source: StructuredOutputError) -> Self
fn from(source: StructuredOutputError) -> Self
Source§impl From<ToolNotFoundError> for Error
impl From<ToolNotFoundError> for Error
Source§fn from(source: ToolNotFoundError) -> Self
fn from(source: ToolNotFoundError) -> Self
Source§impl From<ToolValidationError> for Error
impl From<ToolValidationError> for Error
Source§fn from(source: ToolValidationError) -> Self
fn from(source: ToolValidationError) -> Self
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> 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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 more