diff --git a/src/data.rs b/src/data.rs index 4ff7cc2d..c3cf5345 100644 --- a/src/data.rs +++ b/src/data.rs @@ -737,8 +737,7 @@ fn create_button( #[cfg(test)] mod tests { use super::*; - - use std::error::Error as ErrorTrait; + use ::logging::ProblemPanic; const THIS_FILE: &str = file!(); @@ -786,7 +785,8 @@ mod tests { Err(e) => { let mut handled = false; if let Error::Yaml(ye) = &e { - handled = ye.description() == "missing field `views`"; + handled = ye.to_string() + .starts_with("missing field `views`"); }; if !handled { println!("Unexpected error {:?}", e); @@ -804,7 +804,7 @@ mod tests { Err(e) => { let mut handled = false; if let Error::Yaml(ye) = &e { - handled = ye.description() + handled = ye.to_string() .starts_with("unknown field `bad_field`"); }; if !handled { diff --git a/src/locale_config.rs b/src/locale_config.rs index 0595f2b7..959dfde1 100644 --- a/src/locale_config.rs +++ b/src/locale_config.rs @@ -31,22 +31,16 @@ pub enum Error { impl ::std::fmt::Display for Error { fn fmt(&self, out: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - use ::std::error::Error; - out.write_str(self.description()) - } -} - -impl ::std::error::Error for Error { - fn description(&self) -> &str { - match self { + out.write_str(match self { &Error::NotWellFormed => "Language tag is not well-formed.", // this is exception: here we do want exhaustive match so we don't publish version with // missing descriptions by mistake. &Error::__NonExhaustive => panic!("Placeholder error must not be instantiated!"), - } + }) } } + /// Convenience Result alias. type Result = ::std::result::Result;