diff --git a/src/sdl2/filesystem.rs b/src/sdl2/filesystem.rs index a99636b1..77c21c45 100644 --- a/src/sdl2/filesystem.rs +++ b/src/sdl2/filesystem.rs @@ -1,4 +1,5 @@ use std::ffi::{CStr, CString, NulError}; +use std::fmt; use get_error; use libc::c_char; @@ -24,6 +25,18 @@ pub enum PrefPathError { SdlError(String), } +impl fmt::Display for PrefPathError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use self::PrefPathError::*; + + match *self { + InvalidOrganizationName(ref e) => write!(f, "Invalid organization name: {}", e), + InvalidApplicationName(ref e) => write!(f, "Invalid application name: {}", e), + SdlError(ref e) => write!(f, "SDL error: {}", e) + } + } +} + // TODO: Change to OsStr or something? /// Return the preferred directory for the application to write files on this /// system, based on the given organization and application name.