use crate::futures; use crate::graphics; #[cfg(feature = "winit")] use crate::shell; /// An error that occurred while running an application. #[derive(Debug, thiserror::Error)] pub enum Error { /// The futures executor could not be created. #[error("the futures executor could not be created")] ExecutorCreationFailed(futures::io::Error), /// The application window could not be created. #[error("the application window could not be created")] WindowCreationFailed(Box), /// The application graphics context could not be created. #[error("the application graphics context could not be created")] GraphicsCreationFailed(graphics::Error), /// There was an event loop error. #[error("there was an event loop error")] EventLoop(Box), } #[cfg(feature = "winit")] impl From for Error { fn from(error: shell::Error) -> Error { match error { shell::Error::ExecutorCreationFailed(error) => { Error::ExecutorCreationFailed(error) } #[cfg(feature = "winit")] shell::Error::WindowCreationFailed(error) => { Error::WindowCreationFailed(Box::new(error)) } shell::Error::GraphicsCreationFailed(error) => { Error::GraphicsCreationFailed(error) } shell::Error::EventLoop(error) => Error::EventLoop(Box::new(error)), } } } #[cfg(test)] mod tests { use super::*; #[test] fn assert_send_sync() { fn _assert() {} _assert::(); } }