diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
commit | c52a05e6d3977efce6bd4479aa312dc90e0452e5 (patch) | |
tree | c383c910c1467b406e332651906e081c599d6951 /stockton-render/src/error.rs | |
parent | d5b9ccd3d4a6e5b35a0411688bfb7113f5c7d631 (diff) |
feat(render): proper error handling
Diffstat (limited to 'stockton-render/src/error.rs')
-rw-r--r-- | stockton-render/src/error.rs | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/stockton-render/src/error.rs b/stockton-render/src/error.rs index 7c9abd4..73726b2 100644 --- a/stockton-render/src/error.rs +++ b/stockton-render/src/error.rs @@ -1,41 +1,8 @@ //! Error types -use super::draw::target::TargetChainCreationError; +use anyhow; use thiserror::Error; -/// An error encountered creating a rendering context. -#[derive(Debug)] -pub enum CreationError { - TargetChainCreationError(TargetChainCreationError), - WindowError, - BadSurface, - - DeviceError(hal::device::CreationError), - - OutOfMemoryError, - - SyncObjectError, - - NoShaderC, - ShaderCError(shaderc::Error), - ShaderModuleFailed(hal::device::ShaderError), - RenderPassError, - PipelineError(hal::pso::CreationError), - BufferError(hal::buffer::CreationError), - BufferNoMemory, - - SwapchainError, - ImageViewError, - - BadDataError, -} - -/// An error encountered when rendering. -/// Usually this is out of memory or something happened to the device/surface. -/// You'll likely need to exit or create a new context. -#[derive(Debug, Clone)] -pub enum FrameError {} - #[derive(Error, Debug)] pub enum LockPoisoned { #[error("Device lock poisoned")] @@ -46,4 +13,46 @@ pub enum LockPoisoned { #[error("Queue lock poisoned")] Queue, + + #[error("Other lock poisoned")] + Other, +} + +/// Indicates the given property has no acceptable values +#[derive(Debug, Error)] +pub enum EnvironmentError { + #[error("No supported color format")] + ColorFormat, + + #[error("No supported depth format")] + DepthFormat, + + #[error("No supported present mode")] + PresentMode, + + #[error("No supported composite alpha mode")] + CompositeAlphaMode, + + #[error("No suitable queue families found")] + NoSuitableFamilies, + + #[error("No suitable memory types found")] + NoMemoryTypes, + + #[error("Couldn't use shaderc")] + NoShaderC, + + #[error("No suitable queues")] + NoQueues, +} + +pub fn full_error_display(err: anyhow::Error) -> String { + let cont = err + .chain() + .skip(1) + .map(|cause| format!(" caused by: {}", cause)) + .collect::<Vec<String>>() + .join("\n"); + + format!("Error: {}\n{}", err, cont) } |