pub enum ApiError {
Unauthorized {
body: String,
},
Forbidden {
body: String,
},
NotFound {
path: String,
body: String,
},
RateLimited {
retry_after: Option<u64>,
body: String,
},
ClientError {
status: u16,
body: String,
},
ServerError {
status: u16,
body: String,
},
Request(Error),
Decode(Error),
InvalidMethod(String),
InvalidHeader(String),
UnexpectedResponse(String),
Io(Error),
}Expand description
HTTP and API-layer failures from crate::client::RommClient.
Variants§
Fields
Forbidden
NotFound
RateLimited
ClientError
ServerError
Request(Error)
Decode(Error)
InvalidMethod(String)
InvalidHeader(String)
UnexpectedResponse(String)
Io(Error)
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn from_http_response(status: StatusCode, body: impl Into<String>) -> Self
pub fn from_http_response(status: StatusCode, body: impl Into<String>) -> Self
Map an HTTP status code and response body to a typed variant.
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
HTTP status when this error represents an API response failure.
Sourcepub fn is_auth_failure(&self) -> bool
pub fn is_auth_failure(&self) -> bool
True for 401/403 — callers may prompt re-authentication.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
True when the error body or display text indicates a 404 (URL fallback logic).
Sourcepub fn redacted_for_log(&self) -> String
pub fn redacted_for_log(&self) -> String
Log-safe summary: status and variant only; HTTP response bodies are omitted.
Trait Implementations§
Source§impl Error for ApiError
impl Error for ApiError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<ApiError> for DownloadError
impl From<ApiError> for DownloadError
Auto Trait Implementations§
impl !RefUnwindSafe for ApiError
impl !UnwindSafe for ApiError
impl Freeze for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl UnsafeUnpin for ApiError
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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