use thiserror::Error;
use crate::object::AuthError;
#[derive(Error, Debug)]
pub enum Error {
#[error("Header algorithm unspecified")]
HeaderAlgorithmUnspecified,
#[error("Apple Keys Error")]
AppleKeys,
#[error("Key ID not found")]
KidNotFound,
#[error("Key not found")]
KeyNotFound,
#[error("Iss claim mismatch")]
IssClaimMismatch,
#[error("Client ID mismatch")]
ClientIdMismatch,
#[error(transparent)]
Jwt(#[from] jsonwebtoken::errors::Error),
#[error("serde_json error: {0}")]
SerdeJson(#[from] serde_json::Error),
#[error("hyper error: {0}")]
Hyper(#[from] hyper::Error),
#[error("http error: {0}")]
Http(#[from] hyper::http::Error),
#[error("Time error")]
SystemTime,
#[error("Token Sign Failed")]
SignWithKey,
#[error("Auth Validation HTTP request failed: {0}")]
HttpError(String),
#[error("Bad Auth Validation Request: {0}")]
BadRequest(#[from] AuthError),
#[error("Reqwest error: {0}")]
ReqwestClient(#[from] reqwest::Error),
#[error("PKEY error: {0}")]
PkeyCreation(#[from] openssl::error::ErrorStack),
}
pub type Result<T> = std::result::Result<T, Error>;