pub enum Error {
Authentication {
message: String,
status: u16,
code: Option<String>,
},
InsufficientCredits {
message: String,
status: u16,
code: Option<String>,
balance: i64,
required: i64,
},
InvalidRequest {
message: String,
status: u16,
code: Option<String>,
},
RateLimit {
message: String,
status: u16,
code: Option<String>,
retry_after: Duration,
},
JobFailed {
job_id: Option<String>,
reason: String,
},
JobTimeout {
job_id: Option<String>,
elapsed: Duration,
},
Server {
message: String,
status: u16,
code: Option<String>,
},
Network {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
Other(String),
}Expand description
All errors returned by the Anakin SDK. Match on a specific variant to
react to a particular failure mode (e.g. Error::InsufficientCredits),
or treat the enum as opaque for a generic fallback.
Variants§
Authentication
401 — invalid or missing API key.
InsufficientCredits
402 — out of credits. balance is the caller’s current balance,
required is the credit cost the failed request would have incurred.
InvalidRequest
400 — validation failure.
RateLimit
429 — rate limited after the SDK exhausted its retry budget.
retry_after is the duration the API asked the client to wait.
JobFailed
Polled job came back with status=“failed”.
JobTimeout
Polling budget exhausted before the job reached a terminal status.
Server
5xx after retries were exhausted.
Network
DNS / connect / read-timeout failure from the underlying HTTP client.
Other(String)
Any other error: serialization, unexpected response shape, etc.
Implementations§
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()
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl !UnwindSafe 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
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.