use reqwest_middleware::reqwest::StatusCode;
use std::{error::Error, fmt::Display};
pub mod client;
pub mod illusts;
pub mod models;
pub mod search;
pub mod tokens;
pub mod ugoira;
pub mod users;
#[cfg(feature = "clap")]
pub use clap;
pub use reqwest_middleware::reqwest;
#[cfg(feature = "sqlx")]
pub use sqlx;
#[derive(Debug, Clone)]
pub enum PixivAppError {
TargetNotFound,
RequestFailed,
MissingLogin,
RateLimitReached,
UnhandledStatus(StatusCode),
Unknown,
}
impl Error for PixivAppError {}
impl Display for PixivAppError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
PixivAppError::TargetNotFound => "Requested endpoint not found",
PixivAppError::RequestFailed => "Request failed, check request parameters!",
PixivAppError::MissingLogin => "Request failed because of missing authorization!",
PixivAppError::RateLimitReached => "Too many requests, try again later",
PixivAppError::UnhandledStatus(s) => s.as_str(),
PixivAppError::Unknown => "An unknown error happened and no data was returned.",
}
)
}
}