diff --git a/src/errors.rs b/src/errors.rs index 24ca556..5df5c49 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -3,6 +3,7 @@ use crate::{ast::InterfaceType, interpreter::Instruction}; use std::{ + error::Error, fmt::{self, Display, Formatter}, result::Result, string::{self, ToString}, @@ -28,6 +29,14 @@ pub struct WasmValueNativeCastError { pub to: InterfaceType, } +impl Error for WasmValueNativeCastError {} + +impl Display for WasmValueNativeCastError { + fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { + write!(formatter, "{:?}", self) + } +} + /// Structure to represent the errors for instructions. #[derive(Debug)] pub struct InstructionError { @@ -47,6 +56,8 @@ impl InstructionError { } } +impl Error for InstructionError {} + impl Display for InstructionError { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { write!( @@ -140,6 +151,8 @@ pub enum InstructionErrorKind { String(string::FromUtf8Error), } +impl Error for InstructionErrorKind {} + impl Display for InstructionErrorKind { fn fmt(&self, formatter: &mut Formatter) -> fmt::Result { match self {