diff --git a/crates/core/result/src/lib.rs b/crates/core/result/src/lib.rs index 5608509d..1f40be19 100644 --- a/crates/core/result/src/lib.rs +++ b/crates/core/result/src/lib.rs @@ -1,3 +1,5 @@ +use std::fmt::Display; + #[cfg(feature = "serde")] #[macro_use] extern crate serde; @@ -28,6 +30,14 @@ pub struct Error { pub location: String, } +impl Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?} occurred in {}", self.error_type, self.location) + } +} + +impl std::error::Error for Error {} + /// Possible error types #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))]