This commit is contained in:
2022-06-13 23:49:10 +00:00
committed by GitHub
parent aff743e1f2
commit be15a388ca
3 changed files with 87 additions and 119 deletions

View File

@@ -1,7 +1,42 @@
use crate::downloader::DownloaderError;
#[cfg(feature = "ugoira")]
use crate::ugoira::UgoiraError;
use tokio::task::JoinError;
#[derive(Debug, derive_more::Display, derive_more::From)]
pub enum PixivDownloaderError {
DownloaderError(DownloaderError),
String(String),
JoinError(JoinError),
#[cfg(feature = "ugoira")]
UgoiraError(UgoiraError),
}
impl From<&str> for PixivDownloaderError {
fn from(p: &str) -> Self {
Self::String(String::from(p))
}
}
#[macro_export]
macro_rules! concat_pixiv_downloader_error {
($exp1:expr, $exp2:expr) => {
$exp1 = match $exp1 {
Ok(x) => {
match $exp2 {
Ok(_) => { Ok(x) }
Err(e) => { Err(PixivDownloaderError::from(e)) }
}
}
Err(e) => {
match $exp2 {
Ok(_) => { Err(e) }
Err(e2) => {
println!("{}", e);
Err(PixivDownloaderError::from(e2))
}
}
}
}
}
}