Implement IntoContext for Arc<Error>
This commit is contained in:
parent
db067003d8
commit
c945f1241e
|
@ -201,6 +201,16 @@ impl IntoContext for Location<'static> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<E> IntoContext for Arc<E>
|
||||
where
|
||||
E: std::error::Error + Send + Sync + 'static,
|
||||
{
|
||||
#[inline]
|
||||
fn into_context(self) -> Context {
|
||||
Context::new(Detail::Error(PrivateError(self)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<C, F> IntoContext for F
|
||||
where
|
||||
C: IntoContext,
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use std::panic::Location;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{How, IntoContext, Context, Detail};
|
||||
use crate::context::PrivateError;
|
||||
use crate::{How, IntoContext, Detail};
|
||||
|
||||
pub trait Explain {
|
||||
type Output;
|
||||
|
@ -73,7 +72,7 @@ where
|
|||
|
||||
#[track_caller]
|
||||
fn context(self, context: impl IntoContext) -> Self::Output {
|
||||
How::new(Context::new(Detail::Error(PrivateError(self))))
|
||||
How::new(self.into_context())
|
||||
.context(context)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue