message: Implement std::error::Error (and fmt::Display) for Error and InitError
diff: @@ -93,6 +93,7 @@ use std::ffi::{CStr, CString};
  use std::mem;
  use std::sync::mpsc::{channel, Receiver, Sender};
  use std::fmt;
  +use std::error;
  use std::marker::Send;
  use std::ptr;
  use std::slice;
  @@ -357,6 +358,31 @@ pub enum Error {
  NoWindowContext = ffi::NO_WINDOW_CONTEXT,
  }
  +impl fmt::Display for Error {
  + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  + use std::error::Error;
  +
  + f.write_str(self.description())
  + }
  +}
  +
  +impl error::Error for Error {
  + fn description(&self) -> &str {
  + match *self {
  + Error::NotInitialized => "NotInitialized",
  + Error::NoCurrentContext => "NoCurrentContext",
  + Error::InvalidEnum => "InvalidEnum",
  + Error::InvalidValue => "InvalidValue",
  + Error::OutOfMemory => "OutOfMemory",
  + Error::ApiUnavailable => "ApiUnavailable",
  + Error::VersionUnavailable => "VersionUnavailable",
  + Error::PlatformError => "PlatformError",
  + Error::FormatUnavailable => "FormatUnavailable",
  + Error::NoWindowContext => "NoWindowContext",
  + }
  + }
  +}
  +
  /// An error callback. This can be supplied with some user data to be passed to
  /// the callback function when it is triggered.
  pub type ErrorCallback<UserData> = Callback<fn(Error, String, &UserData), UserData>;
  @@ -566,8 +592,19 @@ pub enum InitError {
  }
  impl fmt::Display for InitError {
  - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
  - write!(f, "InitError: {:?}", *self)
  + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  + use std::error::Error;
  +
  + f.write_str(self.description())
  + }
  +}
  +
  +impl error::Error for InitError {
  + fn description(&self) -> &str {
  + match *self {
  + InitError::AlreadyInitialized => "Already Initialized",
  + InitError::Internal => "Internal Initialization Error",
  + }
  }
  }
  