Skip to content

Commit f630e25

Browse files
author
Kyle Strohbeck
committed
Implement Error for SDL Error.
1 parent 1a10323 commit f630e25

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/sdl2/sdl.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::error;
12
use std::ffi::{CStr, CString, NulError};
23
use std::fmt;
34
use std::rc::Rc;
@@ -28,6 +29,20 @@ impl fmt::Display for Error {
2829
}
2930
}
3031

32+
impl error::Error for Error {
33+
fn description(&self) -> &str {
34+
use self::Error::*;
35+
36+
match *self {
37+
NoMemError => "out of memory",
38+
ReadError => "error reading from datastream",
39+
WriteError => "error writing to datastream",
40+
SeekError => "error seeking in datastream",
41+
UnsupportedError => "unknown SDL error"
42+
}
43+
}
44+
}
45+
3146
use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT};
3247
/// Only one Sdl context can be alive at a time.
3348
/// Set to false by default (not alive).

0 commit comments

Comments
 (0)