Add IntoContext and Explain for Arc<dyn Error>
This commit is contained in:
parent
8a055af669
commit
0e0eaa8d2e
|
@ -218,6 +218,13 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoContext for Arc<dyn std::error::Error + Send + Sync> {
|
||||
#[inline]
|
||||
fn into_context(self) -> Context {
|
||||
Context::new(Detail::Error(PrivateError(self)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, F> IntoContext for F
|
||||
where
|
||||
C: IntoContext,
|
||||
|
|
|
@ -77,6 +77,16 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl Explain for Arc<dyn std::error::Error + Send + Sync> {
|
||||
type Output = How;
|
||||
|
||||
#[track_caller]
|
||||
fn context(self, context: impl IntoContext) -> Self::Output {
|
||||
How::new(self.into_context())
|
||||
.context(context)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Explain for Option<T> {
|
||||
type Output = Result<T, How>;
|
||||
|
||||
|
|
Loading…
Reference in New Issue