diff options
author | Braden Evans <braden@numericalorder.com> | 2015-08-04 18:01:38 -0700 |
---|---|---|
committer | Braden Evans <braden@numericalorder.com> | 2015-08-04 18:01:38 -0700 |
commit | 9bcfad9f75456e0ec978945ff15ee22baab4a2cf (patch) | |
tree | fd5dcb6505040830564f1d894100c0fbca3090af | |
parent | be0440666b948faa92f6e3a81a2a384490ed9d10 (diff) | |
download | glutin-9bcfad9f75456e0ec978945ff15ee22baab4a2cf.tar.gz glutin-9bcfad9f75456e0ec978945ff15ee22baab4a2cf.zip |
Implement Display, Error for ContextError
-rw-r--r-- | src/lib.rs | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -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 } } - |