use std::fmt::Display;
#[derive(Debug, Clone, Copy, PartialEq)]
#[allow(dead_code)]
pub enum ExitCode {
Unsupported4Colors = 4,
CoefficientOutOfRange = 6,
StreamInconsistent = 7,
ProgressiveUnsupported = 8,
SamplingBeyondTwoUnsupported = 10,
VersionUnsupported = 13,
UnsupportedJpeg = 42,
BadLeptonFile = 102,
GeneralFailure = 1000,
VerificationLengthMismatch = 1004,
VerificationContentMismatch = 1005,
SyntaxError = 1006,
FileNotFound = 1007,
}
impl Display for ExitCode {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
#[derive(Debug)]
pub struct LeptonError {
pub exit_code: ExitCode,
pub message: String,
}
impl Display for LeptonError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{0}: {1}", self.exit_code, self.message)
}
}
impl std::error::Error for LeptonError {}