pub enum ApiError {
Show 14 variants
ApiError {
code: i32,
message: String,
error_detail: Option<String>,
correlation_id: Option<String>,
aggregated_errors: Option<HashMap<String, String>>,
},
LockConflict {
message: String,
detail: Option<LockConflictDetail>,
},
BatchError {
message: String,
aggregated_errors: Option<HashMap<String, String>>,
},
LoginRequired(String),
AccessTokenExpired,
RefreshTokenExpired,
RequestError(Error),
JsonError(Error),
InvalidUrl(ParseError),
NoTokensAvailable,
InvalidToken(String),
SseNotUpgraded {
code: i32,
message: String,
},
SseStreamError(String),
Other(String),
}Expand description
Main error type for the Cloudreve API client
Variants§
ApiError
API returned an error response
Fields
LockConflict
Lock conflict error (40073)
BatchError
Batch operation not fully completed (40081)
LoginRequired(String)
Login required or credential invalid (401, 40020)
AccessTokenExpired
Access token expired and needs refresh
RefreshTokenExpired
Refresh token expired, need to login again
RequestError(Error)
HTTP request error
JsonError(Error)
JSON serialization/deserialization error
InvalidUrl(ParseError)
Invalid URL
NoTokensAvailable
No tokens available
InvalidToken(String)
Invalid JWT token
SseNotUpgraded
SSE connection returned non-SSE response (server returned error before upgrading)
SseStreamError(String)
SSE stream error
Other(String)
Generic error
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn from_response<T>(response: ApiResponse<T>) -> Self
pub fn from_response<T>(response: ApiResponse<T>) -> Self
Create an ApiError from an API response
Sourcepub fn is_token_expired(&self) -> bool
pub fn is_token_expired(&self) -> bool
Check if this error is recoverable by retrying with a refreshed token
Sourcepub fn requires_login(&self) -> bool
pub fn requires_login(&self) -> bool
Check if this error requires login
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<ParseError> for ApiError
impl From<ParseError> for ApiError
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Converts to this type from the input type.
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