Added better error handling

This commit is contained in:
David Johnson 2022-01-16 08:59:29 -06:00
parent e4b1917333
commit dc6fc474be
8 changed files with 136 additions and 105 deletions

17
src/error.rs Normal file
View file

@ -0,0 +1,17 @@
use std::error::Error;
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use thiserror::Error;
#[derive(Error, Debug)]
pub enum SoftBufferError<W: HasRawWindowHandle> {
#[error(
"The provided window returned an unsupported platform: {human_readable_platform_name}."
)]
UnsupportedPlatform {
window: W,
human_readable_platform_name: &'static str,
handle: RawWindowHandle,
},
#[error("Platform error")]
PlatformError(Option<String>, Option<Box<dyn Error>>)
}