hermes_cli/impls/error_wrapper.rs
1use core::fmt::Display;
2
3use hermes_error::types::Error;
4
5pub trait ErrorWrapper {
6 type Value;
7
8 fn wrap_error<M>(self, message: M) -> Result<Self::Value, Error>
9 where
10 M: Display;
11}
12
13impl<T, E> ErrorWrapper for Result<T, E>
14where
15 Error: From<E>,
16{
17 type Value = T;
18
19 fn wrap_error<M>(self, message: M) -> Result<T, Error>
20 where
21 M: Display,
22 {
23 self.map_err(|e| Error::from(e).wrap(message))
24 }
25}