pub enum Error {
Auth(String),
Forbidden(String),
NotFound(String),
Validation(String),
RateLimited {
retry_after_secs: u64,
},
Server {
status: u16,
message: String,
},
Network(String),
Timeout {
secs: u64,
},
Json(Error),
Api {
status: u16,
code: String,
message: String,
},
Other(String),
}Variants§
Auth(String)
401 — invalid or expired token
Forbidden(String)
403 — permission denied
NotFound(String)
404 — resource not found
Validation(String)
422 — validation failure
RateLimited
429 — rate limited
Server
5xx — server-side error
Network(String)
Network-level failure (DNS, connection refused, etc.)
Timeout
Request timed out
Json(Error)
JSON parse failure
Api
Structured API error carrying the server’s machine-readable code
(e.g. document import: unsupported_format, file_too_large).
Other(String)
Any other error
Implementations§
Source§impl Error
impl Error
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if the operation can be safely retried.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Returns the recommended retry delay, if any.
Sourcepub async fn from_response(response: Response) -> Self
pub async fn from_response(response: Response) -> Self
Map an HTTP response into a typed error.
Sourcepub fn user_message(&self) -> String
pub fn user_message(&self) -> String
User-friendly CLI message.
Source§impl Error
impl Error
Sourcepub async fn from_coded_response(response: Response) -> Self
pub async fn from_coded_response(response: Response) -> Self
Like Error::from_response, but preserves the server’s code field
({ error, code, retry } bodies) as Error::Api. 401 and 429 keep
their dedicated variants; bodies without a code fall back to the
generic mapping.
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 !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Forget for Error
impl Freeze for Errorwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ErrorImpl is !null: Freeze,
PhantomData<ErrorImpl>: Freeze,
impl Move for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Errorwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ErrorImpl is !null: UnsafeUnpin,
PhantomData<ErrorImpl>: UnsafeUnpin,
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.