diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-09-20 17:52:53 +0200 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-09-20 17:52:53 +0200 |
commit | f51ace4c7885fa25c146c24181c4d87f5632de3e (patch) | |
tree | fa22f137deaabbc99c2f7bbeb1958b07ab7c2949 /src/lib.rs | |
parent | 907d7621bc9822c2688d1783a5805f8532a92b42 (diff) | |
parent | 82bb047fda3912489d024dbf40613168ded50527 (diff) | |
download | glutin-f51ace4c7885fa25c146c24181c4d87f5632de3e.tar.gz glutin-f51ace4c7885fa25c146c24181c4d87f5632de3e.zip |
Merge pull request #602 from tomaka/api-dispatch-error
[Breaking change] Better error handling in Linux's api dispatch
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -106,11 +106,12 @@ pub trait GlContext { } /// Error that can happen while creating a window or a headless renderer. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Debug)] pub enum CreationError { OsError(String), /// TODO: remove this error NotSupported, + NoBackendAvailable(Box<std::error::Error + Send>), RobustnessNotSupported, OpenGlVersionNotSupported, NoAvailablePixelFormat, @@ -121,6 +122,7 @@ impl CreationError { match *self { CreationError::OsError(ref text) => &text, CreationError::NotSupported => "Some of the requested attributes are not supported", + CreationError::NoBackendAvailable(_) => "No backend is available", CreationError::RobustnessNotSupported => "You requested robustness, but it is \ not supported.", CreationError::OpenGlVersionNotSupported => "The requested OpenGL version is not \ @@ -141,6 +143,13 @@ impl std::error::Error for CreationError { fn description(&self) -> &str { self.to_string() } + + fn cause(&self) -> Option<&std::error::Error> { + match *self { + CreationError::NoBackendAvailable(ref err) => Some(&**err), + _ => None + } + } } /// Error that can happen when manipulating an OpenGL context. |