use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
    #[error(transparent)]
    Utf8(#[from] std::str::Utf8Error),
    #[error(transparent)]
    FromUtf8(#[from] std::string::FromUtf8Error),
    #[error(transparent)]
    FromBytesUntilNull(#[from] std::ffi::FromBytesUntilNulError),
    #[error(transparent)]
    Nul(#[from] std::ffi::NulError),

    #[error("LibCZIAPI invalid argument")]
    LibCziApiInvalidArgument,
    #[error("LibCZIAPI invalid handle")]
    LibCziApiInvalidHandle,
    #[error("LibCZIAPI out of memory")]
    LibCziApiOutOfMemory,
    #[error("LibCZIAPI index out of range")]
    LibCziApiIndexOutOfRange,
    #[error("LibCZIAPI lock-unlock semantic violated")]
    LibCziApiLockUnlockSemanticViolated,
    #[error("LibCZIAPI unspecified error")]
    LibCziApiUnspecifiedError,
    #[error("LibCZIAPI unknown error code: {0}")]
    LibCziApiUnknownError(usize),
    #[error("unknown dimension: {0}")]
    UnknownDimension(String),
    #[error("unknown data type: {0}")]
    UnknownDataType(i32),
    #[error("unknown pixel type: {0}")]
    UnknownPixelType(i32),
    #[error("wrong attachment type: {0}")]
    InvalidAttachmentType(String),
    #[error("raw data is malformed")]
    MalformedData,
}
