alt_failure/
error_message.rs1use core::fmt::{self, Display, Debug};
2
3use Fail;
4use Error;
5
6pub fn err_msg<D: Display + Debug + Sync + Send + 'static>(msg: D) -> Error {
12 Error::from(ErrorMessage { msg })
13}
14
15#[derive(Debug)]
18struct ErrorMessage<D: Display + Debug + Sync + Send + 'static> {
19 msg: D,
20}
21
22impl<D: Display + Debug + Sync + Send + 'static> Fail for ErrorMessage<D> {
23 fn name(&self) -> Option<&str> {
24 Some("failure::ErrorMessage")
25 }
26}
27
28impl<D: Display + Debug + Sync + Send + 'static> Display for ErrorMessage<D> {
29 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
30 Display::fmt(&self.msg, f)
31 }
32}