diff options
Diffstat (limited to '')
| -rw-r--r-- | glutin/src/application.rs | 15 | ||||
| -rw-r--r-- | graphics/src/error.rs | 18 | ||||
| -rw-r--r-- | src/error.rs | 10 | ||||
| -rw-r--r-- | wgpu/src/window/compositor.rs | 2 | ||||
| -rw-r--r-- | winit/src/error.rs | 12 | 
5 files changed, 39 insertions, 18 deletions
diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 27a932fc..146b234e 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -80,12 +80,25 @@ where              .or_else(|_| second_builder.build_windowed(builder, &event_loop))              .map_err(|error| {                  use glutin::CreationError; +                use iced_graphics::Error as ContextError;                  match error {                      CreationError::Window(error) => {                          Error::WindowCreationFailed(error)                      } -                    _ => Error::GraphicsAdapterNotFound, +                    CreationError::OpenGlVersionNotSupported => { +                        Error::ContextCreationFailed( +                            ContextError::VersionNotSupported, +                        ) +                    } +                    CreationError::NoAvailablePixelFormat => { +                        Error::ContextCreationFailed( +                            ContextError::NoAvailablePixelFormat, +                        ) +                    } +                    error => Error::ContextCreationFailed( +                        ContextError::BackendError(error.to_string()), +                    ),                  }              })?; diff --git a/graphics/src/error.rs b/graphics/src/error.rs index c86e326a..77758f54 100644 --- a/graphics/src/error.rs +++ b/graphics/src/error.rs @@ -1,7 +1,19 @@ -/// A graphical error that occurred while running an application. +/// An error that occurred while creating an application's graphical context.  #[derive(Debug, thiserror::Error)]  pub enum Error { -    /// A suitable graphics adapter or device could not be found +    /// The requested backend version is not supported. +    #[error("the requested backend version is not supported")] +    VersionNotSupported, + +    /// Failed to find any pixel format that matches the criteria. +    #[error("failed to find any pixel format that matches the criteria")] +    NoAvailablePixelFormat, + +    /// A suitable graphics adapter or device could not be found.      #[error("a suitable graphics adapter or device could not be found")] -    AdapterNotFound, +    GraphicsAdapterNotFound, + +    /// An error occured in the context's internal backend +    #[error("an error occured in the context's internal backend")] +    BackendError(String),  } diff --git a/src/error.rs b/src/error.rs index 17479c60..83c9b1b6 100644 --- a/src/error.rs +++ b/src/error.rs @@ -11,9 +11,9 @@ pub enum Error {      #[error("the application window could not be created")]      WindowCreationFailed(Box<dyn std::error::Error + Send + Sync>), -    /// A suitable graphics adapter or device could not be found. -    #[error("a suitable graphics adapter or device could not be found")] -    GraphicsAdapterNotFound, +    /// The application context could not be created. +    #[error("the application context could not be created")] +    ContextCreationFailed(iced_graphics::Error),  }  impl From<iced_winit::Error> for Error { @@ -25,8 +25,8 @@ impl From<iced_winit::Error> for Error {              iced_winit::Error::WindowCreationFailed(error) => {                  Error::WindowCreationFailed(Box::new(error))              } -            iced_winit::Error::GraphicsAdapterNotFound => { -                Error::GraphicsAdapterNotFound +            iced_winit::Error::ContextCreationFailed(error) => { +                Error::ContextCreationFailed(error)              }          }      } diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index 64c53607..0b368cbf 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -105,7 +105,7 @@ impl iced_graphics::window::Compositor for Compositor {              settings,              compatible_window,          )) -        .ok_or(Error::AdapterNotFound)?; +        .ok_or(Error::GraphicsAdapterNotFound)?;          let backend = compositor.create_backend(); diff --git a/winit/src/error.rs b/winit/src/error.rs index 8e1d20e8..2dd045d2 100644 --- a/winit/src/error.rs +++ b/winit/src/error.rs @@ -11,17 +11,13 @@ pub enum Error {      #[error("the application window could not be created")]      WindowCreationFailed(winit::error::OsError), -    /// A suitable graphics adapter or device could not be found. -    #[error("a suitable graphics adapter or device could not be found")] -    GraphicsAdapterNotFound, +    /// The application context could not be created. +    #[error("the application context could not be created")] +    ContextCreationFailed(iced_graphics::Error),  }  impl From<iced_graphics::Error> for Error {      fn from(error: iced_graphics::Error) -> Error { -        match error { -            iced_graphics::Error::AdapterNotFound => { -                Error::GraphicsAdapterNotFound -            } -        } +        Error::ContextCreationFailed(error)      }  }  | 
