iced/
error.rs

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