use thiserror::Error;
#[derive(Error, Debug, PartialEq)]
pub enum ZipError {
#[error("provided file is not a zip archive")]
InvalidHeader,
#[error("got error while decompressing object")]
DecompressionError,
#[error("file entry is too large to decompress")]
FileTooLarge,
#[error("got EOF while parsing zip")]
EOF,
#[error("file not exist in zip")]
FileNotFound,
#[error("can't find EOCD in zip")]
NotFoundEOCD,
#[error("got error while parsing zip archive")]
ParseError,
#[error("io error while reading zip: {0:?}")]
IoError(std::io::ErrorKind),
}
impl From<std::io::Error> for ZipError {
fn from(e: std::io::Error) -> Self {
ZipError::IoError(e.kind())
}
}
#[derive(Error, Debug)]
pub enum CertificateError {
#[error("got error while parsing certificate")]
ParseError,
#[error("got zip error while parsing certificate: {0}")]
ZipError(#[from] ZipError),
#[error("got signer error")]
SignerError,
#[error("size of blocks not equals (required by format) - (start - {0}, end - {1})")]
InvalidFormat(u64, u64),
}