use thiserror::Error;
use wgpu::RequestAdapterError;
use wgpu::RequestDeviceError;
use winit::error::EventLoopError;

/// Convenience type
pub type AleaticoResult<T> = Result<T, AleaticoError>;

/// All possible errors
#[derive(Error, Debug)]
pub enum AleaticoError {
    /// Event loop error
    #[error(transparent)]
    EventLoopError(#[from] EventLoopError),
    /// Device/surface lost
    #[error("the surface has been lost and needs to be recreated")]
    LostDevice,
    /// Request adapter error
    #[error(transparent)]
    RequestAdapterError(#[from] RequestAdapterError),
    /// Request device error
    #[error(transparent)]
    RequestDeviceError(#[from] RequestDeviceError),
    /// IO Error
    #[error(transparent)]
    IoError(#[from] std::io::Error),
    /// Pipeline not found in internal storage
    #[error("pipeline not found")]
    PipelineNotFound,
    /// Texture not found in internal storage
    #[error("texture not found")]
    TextureNotFound,
    /// Mesh not found in internal storage
    #[error("mesh not found")]
    MeshNotFound,
    /// Create surface error
    #[error(transparent)]
    CreateSurfaceError(#[from] wgpu::CreateSurfaceError),
}
