pub enum LlmError {
Show 15 variants
MissingApiKey(String),
HttpClientCreation(String),
Provider(ProviderError),
IoError(String),
JsonParsing(String),
ToolParameterParsing {
tool_name: String,
error: String,
},
OAuthError(String),
UnsupportedContent(String),
MissingProviderUrl {
provider: String,
},
UnknownProvider {
provider: String,
},
EmptyModelSpec,
DuplicateProvider {
provider: String,
field: String,
},
InvalidModelSpec(String),
ProviderRequest(String),
InvalidArgument(String),
}Expand description
Errors that can occur when interacting with LLM providers.
§Other variants
§Authentication
MissingApiKey– A required environment variable (e.g.ANTHROPIC_API_KEY) is not set.OAuthError– OAuth authentication failed (when theoauthfeature is enabled).
§Request/Response
HttpClientCreation– Failed to create the HTTP client (e.g. TLS configuration error).
§Parsing
JsonParsing– Failed to parse or serialize JSON (response body, tool arguments).ToolParameterParsing– Failed to parse tool parameters for a specific tool.IoError– IO error while reading the response stream.
§Content
UnsupportedContent– The message contained only content types this provider doesn’t support (e.g. sending audio to a text-only model).
§Model parsing
UnknownProvider– Provider name is not registered with the model parser.EmptyModelSpec– The model spec did not yield any usable provider.DuplicateProvider– A single-model-only config field was reused across multiple models of the same provider within one alloy spec (e.g. bedrockinferenceProfileArnor openai-compatiblerequestModel).InvalidModelSpec– Aprovider:modelidentity could not be parsed.MissingProviderUrl– Provider endpoint URL has not been configured.ProviderRequest– A provider request, header, or signature could not be constructed (e.g. an SDK builder rejected the input or contained malformed data).InvalidArgument– An upstream client library rejected an argument as invalid.
§Type alias
The crate provides type Result<T> = std::result::Result<T, LlmError> for convenience.
Variants§
MissingApiKey(String)
Environment variable not set or invalid
HttpClientCreation(String)
HTTP client creation failed
Provider(ProviderError)
Normalized provider-side failure carrying retry classification and support diagnostics (HTTP status, request ID, provider error code).
IoError(String)
IO error while reading stream
JsonParsing(String)
JSON parsing/serialization error
ToolParameterParsing
Tool parameter parsing error
OAuthError(String)
OAuth authentication error
UnsupportedContent(String)
The message contained only content types this provider doesn’t support
MissingProviderUrl
Provider endpoint URL has not been configured.
UnknownProvider
Provider name is not registered with the model parser.
EmptyModelSpec
The model spec did not yield any usable provider.
DuplicateProvider
A single-model-only config field was reused across multiple models of the
same provider within one alloy spec (e.g. bedrock inferenceProfileArn
or openai-compatible requestModel).
InvalidModelSpec(String)
A provider:model identity could not be parsed.
ProviderRequest(String)
A provider request body could not be constructed (e.g. an SDK builder rejected the input or contained malformed data).
InvalidArgument(String)
An upstream client library rejected an argument as invalid.
Implementations§
Source§impl LlmError
impl LlmError
pub fn is_retryable(&self) -> bool
pub fn provider(&self) -> Option<&ProviderError>
Trait Implementations§
Source§impl Error for LlmError
impl Error for LlmError
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<InvalidHeaderValue> for LlmError
impl From<InvalidHeaderValue> for LlmError
Source§fn from(error: InvalidHeaderValue) -> Self
fn from(error: InvalidHeaderValue) -> Self
Source§impl From<OAuthError> for LlmError
Available on crate feature codex only.
impl From<OAuthError> for LlmError
codex only.Source§fn from(error: OAuthError) -> Self
fn from(error: OAuthError) -> Self
Source§impl From<OpenAIError> for LlmError
impl From<OpenAIError> for LlmError
Source§fn from(error: OpenAIError) -> Self
fn from(error: OpenAIError) -> Self
Source§impl From<ProviderError> for LlmError
impl From<ProviderError> for LlmError
Source§fn from(source: ProviderError) -> Self
fn from(source: ProviderError) -> Self
Source§impl From<SdkError<ConverseStreamError, Response>> for LlmError
impl From<SdkError<ConverseStreamError, Response>> for LlmError
Source§fn from(e: SdkError<ConverseStreamError>) -> Self
fn from(e: SdkError<ConverseStreamError>) -> Self
Source§impl From<SdkError<ConverseStreamOutputError, RawMessage>> for LlmError
impl From<SdkError<ConverseStreamOutputError, RawMessage>> for LlmError
Source§fn from(e: SdkError<ConverseStreamOutputError, RawMessage>) -> Self
fn from(e: SdkError<ConverseStreamOutputError, RawMessage>) -> Self
Auto Trait Implementations§
impl Freeze for LlmError
impl RefUnwindSafe for LlmError
impl Send for LlmError
impl Sync for LlmError
impl Unpin for LlmError
impl UnsafeUnpin for LlmError
impl UnwindSafe for LlmError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more