diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-09-20 08:42:32 +0200 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-09-20 08:42:32 +0200 |
commit | b9a4f5fbe90a94fbca2e6816b92a129dabfe81fd (patch) | |
tree | 0a825a6212ea192840276d7bb4214322ceb4d209 /src/lib.rs | |
parent | 27385894ac81d28dd984764c65914ca512043c16 (diff) | |
download | glutin-b9a4f5fbe90a94fbca2e6816b92a129dabfe81fd.tar.gz glutin-b9a4f5fbe90a94fbca2e6816b92a129dabfe81fd.zip |
Err when a X connection cannot be created instead of panicking
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. |