Implement Display for PrefPathError.

This commit is contained in:
Kyle Strohbeck
2016-12-09 13:11:42 -06:00
parent a3d386b828
commit 67c99f1801
+13
View File
@@ -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.