Files
gaym/src/error.rs
T
2025-04-26 16:34:12 +03:00

66 lines
2.1 KiB
Rust

use std::io;
use vulkano::{
buffer::AllocateBufferError, command_buffer::CommandBufferExecError, image::AllocateImageError,
memory::allocator::MemoryAllocatorError, pipeline::layout::IntoPipelineLayoutCreateInfoError,
swapchain::FromWindowError, sync::HostAccessError, LoadingError, Validated, ValidationError,
VulkanError,
};
use winit::raw_window_handle::HandleError;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Event loop error: {0}")]
WinitEventLoop(#[from] winit::error::EventLoopError),
#[error("Window creation error: {0}")]
WinitOs(#[from] winit::error::OsError),
#[error("{0}")]
Io(#[from] io::Error),
#[error("PNG decode error: {0}")]
PngDecode(#[from] png::DecodingError),
#[error("Vulkan loading error: {0}")]
Loading(#[from] LoadingError),
#[error("Window handle error: {0}")]
HandleError(#[from] HandleError),
#[error("Vulkan error: {0}")]
Vulkan(#[from] VulkanError),
#[error("Buffer allocation error: {0}")]
BufferAllocation(#[from] AllocateBufferError),
#[error("Command buffer execution error: {0}")]
CommandBufferExec(#[from] CommandBufferExecError),
#[error("Cannot select a physical device")]
NoValidDevice,
#[error("Vulkan surface creation error: {0}")]
FromWindow(#[from] FromWindowError),
#[error("Pipeline layout create error: {0}")]
IntoPipelineLayoutCreateInfo(#[from] IntoPipelineLayoutCreateInfoError),
#[error("Host buffer access error: {0}")]
HostAccess(#[from] HostAccessError),
#[error("Image allocation error: {0}")]
AllocateImage(#[from] AllocateImageError),
#[error("GPU memory allocation error: {0}")]
MemoryAllocator(#[from] MemoryAllocatorError),
#[error("Missing asset/directory: {0}")]
AssetMissing(String),
}
impl From<Box<ValidationError>> for Error {
fn from(value: Box<ValidationError>) -> Self {
log::error!("Validation error: {value}");
panic!();
}
}
impl<T> From<Validated<T>> for Error
where
Error: From<T>,
{
fn from(value: Validated<T>) -> Self {
Error::from(value.unwrap())
}
}