aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-08-05 08:33:36 +0200
committertomaka <pierre.krieger1708@gmail.com>2015-08-05 08:33:36 +0200
commitdff7612e4547aa3ef0acdb83b0cb05e5e865800e (patch)
tree18bccb55605a1ced619fcbdab9b848564367b4f1
parentbe0440666b948faa92f6e3a81a2a384490ed9d10 (diff)
parent3b76b01ccea7fac9fd2110ba7a0778f19402a620 (diff)
downloadglutin-dff7612e4547aa3ef0acdb83b0cb05e5e865800e.tar.gz
glutin-dff7612e4547aa3ef0acdb83b0cb05e5e865800e.zip
Merge pull request #561 from braden/master
Implement Display, Error for ContextError
-rw-r--r--src/lib.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index a958091..802fcf9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -121,7 +121,7 @@ impl CreationError {
match *self {
CreationError::OsError(ref text) => &text,
CreationError::NotSupported => "Some of the requested attributes are not supported",
- CreationError::RobustnessNotSupported => "Your requested robustness, but it is \
+ CreationError::RobustnessNotSupported => "You requested robustness, but it is \
not supported.",
CreationError::OpenGlVersionNotSupported => "The requested OpenGL version is not \
supported.",
@@ -150,6 +150,28 @@ pub enum ContextError {
ContextLost,
}
+impl ContextError {
+ fn to_string(&self) -> &str {
+ use std::error::Error;
+ match *self {
+ ContextError::IoError(ref err) => err.description(),
+ ContextError::ContextLost => "Context lost."
+ }
+ }
+}
+
+impl std::fmt::Display for ContextError {
+ fn fmt(&self, formatter: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+ formatter.write_str(self.to_string())
+ }
+}
+
+impl std::error::Error for ContextError {
+ fn description(&self) -> &str {
+ self.to_string()
+ }
+}
+
/// All APIs related to OpenGL that you can possibly get while using glutin.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Api {
@@ -539,4 +561,3 @@ mod native_monitor {
Unavailable
}
}
-