iced_graphics/error.rs
1//! See what can go wrong when creating graphical backends.
2
3/// An error that occurred while creating an application's graphical context.
4#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
5pub enum Error {
6 /// The requested backend version is not supported.
7 #[error("the requested backend version is not supported")]
8 VersionNotSupported,
9
10 /// Failed to find any pixel format that matches the criteria.
11 #[error("failed to find any pixel format that matches the criteria")]
12 NoAvailablePixelFormat,
13
14 /// A suitable graphics adapter or device could not be found.
15 #[error("a suitable graphics adapter or device could not be found")]
16 GraphicsAdapterNotFound {
17 /// The name of the backend where the error happened
18 backend: &'static str,
19 /// The reason why this backend could not be used
20 reason: Reason,
21 },
22
23 /// An error occurred in the context's internal backend
24 #[error("an error occurred in the context's internal backend")]
25 BackendError(String),
26
27 /// Multiple errors occurred
28 #[error("multiple errors occurred: {0:?}")]
29 List(Vec<Self>),
30}
31
32/// The reason why a graphics adapter could not be found
33#[derive(Debug, Clone, PartialEq, Eq)]
34pub enum Reason {
35 /// The backend did not match the preference
36 DidNotMatch {
37 /// The preferred backend
38 preferred_backend: String,
39 },
40 /// The request to create the backend failed
41 RequestFailed(String),
42}