pub enum LettaError {
Show 13 variants
Http(Error),
Auth {
message: String,
},
Api {
status: u16,
message: String,
code: Option<String>,
body: ErrorBody,
url: Option<Url>,
method: Option<String>,
},
Serde(Error),
Streaming {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Config {
message: String,
},
Url(ParseError),
Io(Error),
UrlEncoding(Error),
RequestTimeout {
seconds: u64,
},
RateLimit {
retry_after: Option<u64>,
},
NotFound {
resource_type: String,
id: String,
},
Validation {
message: String,
field: Option<String>,
},
}Expand description
Comprehensive error type for all Letta client operations.
This error type provides detailed context about failures and implements
miette::Diagnostic for rich error reporting with suggestions and
source code highlighting where applicable.
Variants§
Http(Error)
HTTP request failed.
Auth
Authentication failed.
Api
API returned an error response.
Fields
Serde(Error)
JSON serialization/deserialization failed.
Streaming
Streaming operation failed.
Fields
Config
Client configuration error.
Url(ParseError)
URL parsing error.
Io(Error)
I/O operation failed.
UrlEncoding(Error)
URL encoding error.
RequestTimeout
Request timeout.
RateLimit
Rate limit exceeded.
NotFound
Resource not found.
Validation
Validation error for request parameters.
Implementations§
Source§impl LettaError
impl LettaError
Sourcepub fn api_with_code(
status: u16,
message: impl Into<String>,
code: impl Into<String>,
) -> Self
pub fn api_with_code( status: u16, message: impl Into<String>, code: impl Into<String>, ) -> Self
Create a new API error with error code.
Sourcepub fn from_response(status: u16, body_str: String) -> Self
pub fn from_response(status: u16, body_str: String) -> Self
Create a new API error from response body. Automatically parses and structures the error body and maps to specific error types.
Sourcepub fn from_response_with_headers(
status: u16,
body_str: String,
headers: Option<&HeaderMap>,
) -> Self
pub fn from_response_with_headers( status: u16, body_str: String, headers: Option<&HeaderMap>, ) -> Self
Create a new API error from response body with optional headers. Automatically parses and structures the error body and maps to specific error types.
Sourcepub fn from_response_with_context(
status: u16,
body_str: String,
headers: Option<&HeaderMap>,
url: Option<Url>,
method: Option<String>,
) -> Self
pub fn from_response_with_context( status: u16, body_str: String, headers: Option<&HeaderMap>, url: Option<Url>, method: Option<String>, ) -> Self
Create a new API error from response body with full context. Automatically parses and structures the error body and maps to specific error types.
Sourcepub fn api_with_body(
status: u16,
message: impl Into<String>,
body: ErrorBody,
) -> Self
pub fn api_with_body( status: u16, message: impl Into<String>, body: ErrorBody, ) -> Self
Create a new API error with specific error body.
Sourcepub fn streaming_with_source(
message: impl Into<String>,
source: impl Into<Box<dyn Error + Send + Sync>>,
) -> Self
pub fn streaming_with_source( message: impl Into<String>, source: impl Into<Box<dyn Error + Send + Sync>>, ) -> Self
Create a new streaming error with source.
Sourcepub fn not_found(
resource_type: impl Into<String>,
id: impl Into<String>,
) -> Self
pub fn not_found( resource_type: impl Into<String>, id: impl Into<String>, ) -> Self
Create a new not found error.
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Create a new validation error.
Sourcepub fn validation_field(
message: impl Into<String>,
field: impl Into<String>,
) -> Self
pub fn validation_field( message: impl Into<String>, field: impl Into<String>, ) -> Self
Create a new validation error for a specific field.
Sourcepub fn request_timeout(seconds: u64) -> Self
pub fn request_timeout(seconds: u64) -> Self
Create a new request timeout error.
Sourcepub fn rate_limit(retry_after: Option<u64>) -> Self
pub fn rate_limit(retry_after: Option<u64>) -> Self
Create a new rate limit error.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Check if this error is retryable.
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
Get the HTTP status code if this is an API error.
Sourcepub fn response_body(&self) -> Option<&ErrorBody>
pub fn response_body(&self) -> Option<&ErrorBody>
Get the structured response body if this is an API error.
Sourcepub fn error_code(&self) -> Option<&str>
pub fn error_code(&self) -> Option<&str>
Get the error code if this is an API error.
Check if this is a specific type of API error.
Sourcepub fn is_validation_error(&self) -> bool
pub fn is_validation_error(&self) -> bool
Check if this is a validation error.
Get the unauthorized error details if this is an unauthorized error.
Trait Implementations§
Source§impl Debug for LettaError
impl Debug for LettaError
Source§impl Diagnostic for LettaError
impl Diagnostic for LettaError
Source§fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic. Ideally also globally unique, and documented
in the toplevel crate’s documentation for easy searching. Rust path
format (foo::bar::baz) is recommended, but more classic codes like
E0123 or enums will work just fine.Source§fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic. Do you have any
advice for the poor soul who’s just run into this issue?Source§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandlers to change the display format
of this diagnostic. Read moreSource§fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
fn url<'a>(&'a self) -> Option<Box<dyn Display + 'a>>
Diagnostic.Source§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic’s Diagnostic::labels to.Source§fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic’s Diagnostic::source_codeDiagnostics.Source§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
Source§impl Display for LettaError
impl Display for LettaError
Source§impl Error for LettaError
impl Error for LettaError
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
Source§impl From<Error> for LettaError
impl From<Error> for LettaError
Source§impl From<Error> for LettaError
impl From<Error> for LettaError
Source§impl From<Error> for LettaError
impl From<Error> for LettaError
Source§impl From<Error> for LettaError
impl From<Error> for LettaError
Source§impl From<ParseError> for LettaError
impl From<ParseError> for LettaError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Source§impl Retryable for LettaError
impl Retryable for LettaError
Source§fn is_retryable(&self) -> bool
fn is_retryable(&self) -> bool
Source§fn retry_after(&self) -> Option<Duration>
fn retry_after(&self) -> Option<Duration>
Auto Trait Implementations§
impl Freeze for LettaError
impl !RefUnwindSafe for LettaError
impl Send for LettaError
impl Sync for LettaError
impl Unpin for LettaError
impl !UnwindSafe for LettaError
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
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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.