use strum::IntoStaticStr;
use thiserror::Error;
#[derive(Debug, Error, IntoStaticStr)]
pub enum Error {
#[error(transparent)]
IO(#[from] std::io::Error),
#[error(transparent)]
Shape(#[from] ndarray::ShapeError),
#[cfg(feature = "bioformats_java")]
#[error(transparent)]
J4rs(#[from] j4rs::errors::J4RsError),
#[error(transparent)]
Infallible(#[from] std::convert::Infallible),
#[error(transparent)]
ParseIntError(#[from] std::num::ParseIntError),
#[error(transparent)]
Ome(#[from] ome_metadata::error::Error),
#[cfg(feature = "bioformats_java")]
#[error(transparent)]
Downloader(#[from] downloader::Error),
#[error(transparent)]
Strum(#[from] strum::ParseError),
#[cfg(feature = "tiffwrite")]
#[error(transparent)]
TemplateError(#[from] indicatif::style::TemplateError),
#[cfg(feature = "tiffwrite")]
#[error(transparent)]
TiffWrite(#[from] tiffwrite::error::Error),
#[cfg(feature = "tiffseq")]
#[error(transparent)]
SerdeYaml(#[from] serde_yaml::Error),
#[cfg(any(feature = "tiffseq", feature = "tiff"))]
#[error(transparent)]
Tiff(#[from] tiff::TiffError),
#[cfg(feature = "python")]
#[error(transparent)]
PostCard(#[from] postcard::Error),
#[cfg(feature = "czi")]
#[error(transparent)]
LibCzi(#[from] libczirw_sys::error::Error),
#[error(transparent)]
RegexError(#[from] regex::Error),
#[cfg(feature = "czi")]
#[error(transparent)]
XmlTree(#[from] xmltree::Error),
#[cfg(feature = "czi")]
#[error(transparent)]
XmlTreeParse(#[from] xmltree::ParseError),
#[cfg(feature = "czi")]
#[error(transparent)]
Czi(#[from] crate::readers::czi::CziError),
#[cfg(feature = "movie")]
#[error(transparent)]
TokioJoin(#[from] tokio::task::JoinError),
#[cfg(feature = "bioformats_rust")]
#[error(transparent)]
BioFormats(#[from] bioformats::error::BioFormatsError),
#[error("invalid axis: {0}")]
InvalidAxis(String),
#[error("axis {0} not found in axes {1}")]
AxisNotFound(String, String),
#[error("conversion error: {0}")]
TryInto(String),
#[error("file already exists {0}")]
FileAlreadyExists(String),
#[error("could not download ffmpeg: {0}")]
FfmpegDownload(String),
#[error("FFmpeg error: {0}")]
Ffmpeg(String),
#[error("index {0} out of bounds {1}")]
OutOfBounds(isize, isize),
#[error("axis {0} has length {1}, but was not included")]
OutOfBoundsAxis(String, usize),
#[error("dimensionality mismatch: {0} != {0}")]
DimensionalityMismatch(usize, usize),
#[error("axis {0}: {1} is already operated on!")]
AxisAlreadyOperated(usize, String),
#[error("not enough free dimensions")]
NotEnoughFreeDimensions,
#[error("cannot cast {0} to {1}")]
Cast(String, String),
#[error("empty view")]
EmptyView,
#[error("invalid color: {0}")]
InvalidColor(String),
#[error("no image or pixels found")]
NoImageOrPixels,
#[error("invalid attenuation value: {0}")]
InvalidAttenuation(String),
#[error("not a valid file name")]
InvalidFileName,
#[error("file has no parent")]
NoParent,
#[error("unknown pixel type {0}")]
UnknownPixelType(String),
#[error("no mean")]
NoMean,
#[error("tiff is locked")]
TiffLock,
#[error("not implemented: {0}")]
NotImplemented(String),
#[error("cannot parse: {0}")]
Parse(String),
#[error("cannot convert libczi pixel type: {0}")]
Conversion(String),
#[error("no reader found for {0}, tried: {1}")]
NoReader(String, String),
#[error("reader {0} cannot open file {1} because {2}")]
InvalidReader(String, String, String),
#[error("file does not exist: {0}")]
FileDoesNotExist(String),
#[error("cannot remove axes {0}, size {1} != 1")]
SizeMismatch(String, usize),
}
impl Error {
pub fn variant_name(&self) -> &'static str {
self.into()
}
}