summaryrefslogtreecommitdiffstats
path: root/graphics/src/error.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-03-25 21:36:44 +0100
committerLibravatar GitHub <noreply@github.com>2024-03-25 21:36:44 +0100
commita2a8381a49ac2dd1cd65eb382b9ee02bbfa17286 (patch)
treee6c24928a42e23ff91eea0fc30b4fbbcb6da024b /graphics/src/error.rs
parent3013463baa71504488a20436beb3db87ecb66df0 (diff)
parent6a4f5ac2081699f7cf20c917b367366ab49eeef1 (diff)
downloadiced-a2a8381a49ac2dd1cd65eb382b9ee02bbfa17286.tar.gz
iced-a2a8381a49ac2dd1cd65eb382b9ee02bbfa17286.tar.bz2
iced-a2a8381a49ac2dd1cd65eb382b9ee02bbfa17286.zip
Merge pull request #2351 from iced-rs/custom-renderer-injection
Type-Driven Renderer Fallback
Diffstat (limited to 'graphics/src/error.rs')
-rw-r--r--graphics/src/error.rs27
1 files changed, 25 insertions, 2 deletions
diff --git a/graphics/src/error.rs b/graphics/src/error.rs
index c6ea98a3..6ea1d3a4 100644
--- a/graphics/src/error.rs
+++ b/graphics/src/error.rs
@@ -1,5 +1,7 @@
+//! See what can go wrong when creating graphical backends.
+
/// An error that occurred while creating an application's graphical context.
-#[derive(Debug, thiserror::Error)]
+#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum Error {
/// The requested backend version is not supported.
#[error("the requested backend version is not supported")]
@@ -11,9 +13,30 @@ pub enum Error {
/// A suitable graphics adapter or device could not be found.
#[error("a suitable graphics adapter or device could not be found")]
- GraphicsAdapterNotFound,
+ GraphicsAdapterNotFound {
+ /// The name of the backend where the error happened
+ backend: &'static str,
+ /// The reason why this backend could not be used
+ reason: Reason,
+ },
/// An error occurred in the context's internal backend
#[error("an error occurred in the context's internal backend")]
BackendError(String),
+
+ /// Multiple errors occurred
+ #[error("multiple errors occurred: {0:?}")]
+ List(Vec<Self>),
+}
+
+/// The reason why a graphics adapter could not be found
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum Reason {
+ /// The backend did not match the preference
+ DidNotMatch {
+ /// The preferred backend
+ preferred_backend: String,
+ },
+ /// The request to create the backend failed
+ RequestFailed(String),
}