pub enum Error {
Show 14 variants
Http(Error),
Json(Error),
Io(Error),
Api {
code: i32,
message: String,
},
ApiWithData {
code: i32,
message: String,
data: Value,
},
Aggregate {
code: i32,
message: String,
errors: HashMap<String, AggregatedItemError>,
},
Auth(String),
InvalidResponse(String),
InvalidTimestamp(String),
UnsupportedFeature(String, String),
TwoFactorRequired(String),
Unauthorized(String),
CaptchaRequired,
CaptchaInvalid(String),
}Expand description
Main error type for the Cloudreve API client
Variants§
Http(Error)
HTTP request error
Json(Error)
JSON serialization/deserialization error
Io(Error)
IO error
Api
API error response
ApiWithData
API error whose payload the caller needs to act on
Some business codes put actionable data in data — a lock conflict
(40073) returns the unlock tokens there. Error::Api drops it, so
endpoints whose callers must react to the payload report it here.
Aggregate
A batch operation completed only partially (code: 40081)
errors is keyed by the URI that was sent; every URI absent from the
map succeeded. Each entry carries its own business code, so a locked
file surfaces as a 40073 sub-item with tokens in its data.
Auth(String)
Authentication error
InvalidResponse(String)
Invalid response error
InvalidTimestamp(String)
Invalid timestamp error
UnsupportedFeature(String, String)
Feature not supported in API version
TwoFactorRequired(String)
Two-factor authentication required (code: 203) Contains the session ID needed for 2FA completion
Unauthorized — application-level 401 returned in JSON body
CaptchaRequired
CAPTCHA required for login
CaptchaInvalid(String)
CAPTCHA validation failed
Implementations§
Source§impl Error
impl Error
Sourcepub fn message(&self) -> Option<&str>
pub fn message(&self) -> Option<&str>
Server message of an API-level error, without the code decoration that
std::fmt::Display adds.
Sourcepub fn data(&self) -> Option<&Value>
pub fn data(&self) -> Option<&Value>
Response payload of an API-level error, if the variant kept one.
Sourcepub fn aggregated_errors(&self) -> Option<&HashMap<String, AggregatedItemError>>
pub fn aggregated_errors(&self) -> Option<&HashMap<String, AggregatedItemError>>
Per-item failures of a partially completed batch operation.
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()
Source§impl From<Error> for Error
impl From<Error> for Error
Source§fn from(source: ReqwestError) -> Self
fn from(source: ReqwestError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin 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.