use image::ImageError;
#[cfg(feature = "read-raw-image")]
use rawloader::RawLoaderError;
use std::fmt::{Debug, Display, Formatter};
use std::io;
use thiserror::Error;
#[derive(Error, Debug)]
pub struct RawPipelineError(pub String);
impl Display for RawPipelineError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
impl From<String> for RawPipelineError {
fn from(value: String) -> Self {
Self(value)
}
}
#[derive(Error, Debug)]
pub struct UnknownError(pub String);
impl Display for UnknownError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
impl From<String> for UnknownError {
fn from(value: String) -> Self {
Self(value)
}
}
#[derive(Debug, Error)]
pub enum Error {
#[error("Unable to decode raw image")]
#[cfg_attr(not(feature = "read-raw-image"), non_exhaustive)]
DecodeError(
#[from]
#[cfg(feature = "read-raw-image")]
RawLoaderError,
),
#[error("Unable to decode raw image")]
RawPipeline(#[from] RawPipelineError),
#[error("Unable to read exif data")]
ExifError(#[from] exif::Error),
#[error("Unable to read file")]
IoError(#[from] io::Error),
#[error("Unable to process image")]
ImageError(#[from] ImageError),
#[error("Invalid value for {parameter_name:?}: {message:?}")]
InputError {
parameter_name: String,
message: String,
},
#[error("{0}")]
UnknownError(#[from] UnknownError),
}