1use std::fmt::{Debug, Display, Formatter};
2
3pub type Result<T, E = Error> = std::result::Result<T, E>;
7
8pub type BoxError = Box<dyn std::error::Error + Send + Sync>;
9
10pub struct Error(Box<dyn Display + Send + Sync>);
11
12impl Error {
13 pub fn new<E: Display + Send + Sync + 'static>(error: E) -> Self {
14 Self(Box::new(error))
15 }
16}
17
18impl Debug for Error {
19 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
20 self.0.fmt(f)
21 }
22}
23
24impl Display for Error {
25 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
26 self.0.fmt(f)
27 }
28}
29
30impl std::error::Error for Error {}