diff --git a/src/error.rs b/src/error.rs index ffe79b6aa2..c7f742dd6b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,8 +1,10 @@ use crate::host; use crate::sys::errno_from_ioerror; +use failure::Fail; +use std::fmt; use std::num::TryFromIntError; -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Fail)] pub enum WasiError { ESUCCESS = 0, E2BIG = 1, @@ -89,6 +91,15 @@ impl WasiError { } } +impl fmt::Display for WasiError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + _ => write!(f, "{:?}", self), + } + } +} + +#[derive(Debug, Fail)] pub enum Error { Wasi(WasiError), Io(std::io::Error), @@ -228,3 +239,11 @@ impl Error { pub const EXDEV: Self = Error::Wasi(WasiError::EXDEV); pub const ENOTCAPABLE: Self = Error::Wasi(WasiError::ENOTCAPABLE); } + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + _ => write!(f, "{:?}", self), + } + } +}