pub enum DownloadError {
Reqwest(Error),
ReqwestMiddleware(Error),
Tokio(Error),
Url(ParseError),
Indicatif(TemplateError),
Join(JoinError),
Custom(String),
}Expand description
Error type returned by all fallible operations in this library.
Each variant wraps the underlying error from the relevant subsystem, so
callers can pattern-match on specific failure modes or rely on the
Display impl for a human-readable message.
§Examples
use cc_downloader::download::{DownloadOptions, download_paths};
use cc_downloader::errors::DownloadError;
let options = DownloadOptions {
snapshot: "CC-MAIN-2024-46".to_string(),
data_type: "wet",
dst: std::path::Path::new("./output"),
..Default::default()
};
match download_paths(options).await {
Ok(_) => println!("Done"),
Err(DownloadError::Custom(msg)) => eprintln!("Resource not found: {msg}"),
Err(e) => eprintln!("Download failed: {e}"),
}Variants§
Reqwest(Error)
An error from the underlying HTTP client (reqwest).
ReqwestMiddleware(Error)
An error from the retry middleware (reqwest_middleware).
Tokio(Error)
An I/O error, either from tokio::io or the standard library.
Url(ParseError)
A URL parsing error.
Indicatif(TemplateError)
An error constructing a progress bar template (indicatif).
Join(JoinError)
A task join error from the async runtime.
Custom(String)
A domain-level error, e.g. an unrecognised snapshot reference or an
inaccessible paths URL. The inner String contains the full message
printed to the user.
Trait Implementations§
Source§impl Debug for DownloadError
impl Debug for DownloadError
Source§impl Display for DownloadError
impl Display for DownloadError
Source§impl From<Error> for DownloadError
impl From<Error> for DownloadError
Source§impl From<Error> for DownloadError
impl From<Error> for DownloadError
Source§impl From<Error> for DownloadError
impl From<Error> for DownloadError
Source§impl From<JoinError> for DownloadError
impl From<JoinError> for DownloadError
Source§impl From<ParseError> for DownloadError
impl From<ParseError> for DownloadError
Source§fn from(err: ParseError) -> Self
fn from(err: ParseError) -> Self
Converts to this type from the input type.
Source§impl From<String> for DownloadError
impl From<String> for DownloadError
Source§fn from(s: String) -> DownloadError
fn from(s: String) -> DownloadError
Converts to this type from the input type.
Source§impl From<TemplateError> for DownloadError
impl From<TemplateError> for DownloadError
Source§fn from(err: TemplateError) -> Self
fn from(err: TemplateError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for DownloadError
impl !UnwindSafe for DownloadError
impl Freeze for DownloadError
impl Send for DownloadError
impl Sync for DownloadError
impl Unpin for DownloadError
impl UnsafeUnpin for DownloadError
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> 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.