#[non_exhaustive]pub enum Error {
InvalidTask(String),
Network(Error),
BadResponse {
message: String,
raw: String,
},
Api {
error_id: i64,
error_code: String,
description: String,
},
Timeout(u64),
Io {
path: String,
source: Error,
},
}Expand description
Errors returned by this library.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
InvalidTask(String)
A task is missing a required parameter, or a value is out of range. Nothing was sent to the API.
Network(Error)
The API could not be reached.
BadResponse
The API answered with something that is not the JSON we expect.
Api
The API answered with a non-zero errorId.
See https://anti-captcha.com/apidoc/errors for the list of codes.
Timeout(u64)
The task was still unsolved when the waiting limit ran out.
Io
A captcha image file could not be read.
Implementations§
Source§impl Error
impl Error
Sourcepub fn api_error_code(&self) -> Option<&str>
pub fn api_error_code(&self) -> Option<&str>
The API error code, e.g. ERROR_ZERO_BALANCE, when this is an Error::Api.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
True when retrying the very same task could still succeed.
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)>
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()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Forget for Error
impl Freeze for Error
impl Move 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
Mutably borrows from an owned value. Read more