aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-09-20 08:42:32 +0200
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-09-20 08:42:32 +0200
commitb9a4f5fbe90a94fbca2e6816b92a129dabfe81fd (patch)
tree0a825a6212ea192840276d7bb4214322ceb4d209 /src/lib.rs
parent27385894ac81d28dd984764c65914ca512043c16 (diff)
downloadglutin-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.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 94cd445..24913fb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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.