1use core::fmt;
2
3pub type BoxError = alloc::boxed::Box<dyn core::error::Error + Send + Sync>;
5pub type CloneableError = alloc::sync::Arc<dyn core::error::Error + Send + Sync>;
6
7#[derive(Debug, Clone)]
9pub struct Error {
10 inner: CloneableError,
11}
12
13impl Error {
14 pub fn new(error: impl Into<BoxError>) -> Self {
16 Self {
17 inner: CloneableError::from(error.into()),
18 }
19 }
20
21 pub fn into_inner(self) -> CloneableError {
23 self.inner
24 }
25}
26
27impl fmt::Display for Error {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 self.inner.fmt(f)
30 }
31}
32
33impl core::error::Error for Error {
34 fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
35 Some(&*self.inner)
36 }
37}