1use crate::futures;
2use crate::graphics;
3#[cfg(feature = "winit")]
4use crate::shell;
5
6#[derive(Debug, thiserror::Error)]
8pub enum Error {
9 #[error("the futures executor could not be created")]
11 ExecutorCreationFailed(futures::io::Error),
12
13 #[error("the application window could not be created")]
15 WindowCreationFailed(Box<dyn std::error::Error + Send + Sync>),
16
17 #[error("the application graphics context could not be created")]
19 GraphicsCreationFailed(graphics::Error),
20}
21
22#[cfg(feature = "winit")]
23impl From<shell::Error> for Error {
24 fn from(error: shell::Error) -> Error {
25 match error {
26 shell::Error::ExecutorCreationFailed(error) => {
27 Error::ExecutorCreationFailed(error)
28 }
29 #[cfg(feature = "winit")]
30 shell::Error::WindowCreationFailed(error) => {
31 Error::WindowCreationFailed(Box::new(error))
32 }
33 shell::Error::GraphicsCreationFailed(error) => {
34 Error::GraphicsCreationFailed(error)
35 }
36 }
37 }
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn assert_send_sync() {
46 fn _assert<T: Send + Sync>() {}
47 _assert::<Error>();
48 }
49}