Follow rust std: Error requires an implementation of fmt::Display

This commit is contained in:
Thomas Bahn
2015-02-06 15:37:02 +01:00
parent 5782657502
commit cb8492d74b
2 changed files with 16 additions and 11 deletions
+7 -4
View File
@@ -91,7 +91,7 @@ impl error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::SyntaxError(..) => "syntax error",
Error::IoError(ref error) => error.description(),
Error::IoError(_) => "input/output error",
/*
Error::ExpectedError(ref expected, _) => &expected,
Error::MissingFieldError(_) => "missing field",
@@ -100,12 +100,15 @@ impl error::Error for Error {
}
}
fn detail(&self) -> Option<String> {
}
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::SyntaxError(ref code, line, col) => {
Some(format!("{:?} at line {:?} column {:?}", code, line, col))
write!(fmt, "{:?} at line {:?} column {:?}", code, line, col)
}
Error::IoError(ref error) => error.detail(),
Error::IoError(ref error) => fmt::Display::fmt(error, fmt),
/*
Error::ExpectedError(ref expected, ref found) => {
Some(format!("expected {}, found {}", expected, found))