use std::io::Error as IoError;

use serde_yaml::Error as YamlError;
use thiserror::Error;
use vfs::VfsError;
use vfs_zip::Error as VfsZipError;

#[derive(Debug, Error)]
pub enum Error {
    #[error("IO Error: {0}")]
    IoError(IoError),

    #[error("VFS Error: {0}")]
    VfsError(VfsError),

    #[error("VFS ZIP Error: {0}")]
    VfsZipError(VfsZipError),

    #[error("YAML Error: {0}")]
    YamlError(YamlError),

    #[error("Resource is not registered: {0}!")]
    ResourceNotRegistered(&'static str),

    #[error("Unable to initialize VFS!")]
    InitVFS,
}

impl From<IoError> for Error {
    fn from(err: IoError) -> Self {
        Self::IoError(err)
    }
}

impl From<VfsError> for Error {
    fn from(err: VfsError) -> Self {
        Self::VfsError(err)
    }
}

impl From<VfsZipError> for Error {
    fn from(err: VfsZipError) -> Self {
        Self::VfsZipError(err)
    }
}

impl From<YamlError> for Error {
    fn from(err: YamlError) -> Self {
        Self::YamlError(err)
    }
}
