diff --git a/src/sdl2/sdl.rs b/src/sdl2/sdl.rs index c292095b..09dc9eaf 100644 --- a/src/sdl2/sdl.rs +++ b/src/sdl2/sdl.rs @@ -1,3 +1,4 @@ +use std::error; use std::ffi::{CStr, CString, NulError}; use std::fmt; use std::rc::Rc; @@ -28,6 +29,20 @@ impl fmt::Display for Error { } } +impl error::Error for Error { + fn description(&self) -> &str { + use self::Error::*; + + match *self { + NoMemError => "out of memory", + ReadError => "error reading from datastream", + WriteError => "error writing to datastream", + SeekError => "error seeking in datastream", + UnsupportedError => "unknown SDL error" + } + } +} + use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT}; /// Only one Sdl context can be alive at a time. /// Set to false by default (not alive).