1use std::{ffi::NulError, num::TryFromIntError};
5
6use thiserror::Error;
7
8#[derive(Error, Debug, Clone)]
10pub enum OpenSlideError {
11 #[error("Internal error: {0}")]
14 InternalError(String),
15
16 #[error("Internal error: {0}")]
19 ImageError(String),
20
21 #[error("File {0} does not exist")]
22 MissingFile(String),
23
24 #[error("Unsupported file format: {0}")]
25 UnsupportedFile(String),
26
27 #[error("OpenSlide error: {0}")]
29 CoreError(String),
30}
31
32impl From<TryFromIntError> for OpenSlideError {
33 fn from(err: TryFromIntError) -> Self {
34 OpenSlideError::InternalError(err.to_string())
35 }
36}
37
38impl From<NulError> for OpenSlideError {
39 fn from(err: NulError) -> Self {
40 OpenSlideError::InternalError(err.to_string())
41 }
42}