pub enum ApiError {
Network(String),
Http {
status: u16,
message: String,
},
NotFound(String),
BadRequest(String),
Unauthorized,
Forbidden,
Server(String),
Timeout,
Serialization(String),
Deserialization(String),
Validation(String),
}Expand description
API error types
Variants§
Network(String)
Network error (failed to send request)
Http
HTTP error with status code
NotFound(String)
Resource not found (404)
BadRequest(String)
Bad request (400)
Unauthorized (401)
Forbidden
Forbidden (403)
Server(String)
Server error (5xx)
Timeout
Timeout
Serialization(String)
Serialization error
Deserialization(String)
Deserialization error
Validation(String)
Validation error
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn from_status(status: u16, message: String) -> Self
pub fn from_status(status: u16, message: String) -> Self
Create an error from HTTP status code and message
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Check if the error is recoverable (can retry)
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Check if this is a client error (4xx)
Sourcepub fn status_code(&self) -> Option<u16>
pub fn status_code(&self) -> Option<u16>
Get the HTTP status code if applicable
Trait Implementations§
Source§impl Error for ApiError
impl Error for ApiError
1.30.0 · 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<ApiErrorResponse> for ApiError
impl From<ApiErrorResponse> for ApiError
Source§fn from(resp: ApiErrorResponse) -> Self
fn from(resp: ApiErrorResponse) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for ApiError
Auto Trait Implementations§
impl Freeze for ApiError
impl RefUnwindSafe for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl UnwindSafe 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> 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> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
Source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self to a value of a Properties struct.Source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
Source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self to a value of a Properties struct.