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
|
impl<C, F> IntoContext for F
|
||||||
where
|
where
|
||||||
C: IntoContext,
|
C: IntoContext,
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use std::panic::Location;
|
use std::panic::Location;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::{How, IntoContext, Context, Detail};
|
use crate::{How, IntoContext, Detail};
|
||||||
use crate::context::PrivateError;
|
|
||||||
|
|
||||||
pub trait Explain {
|
pub trait Explain {
|
||||||
type Output;
|
type Output;
|
||||||
|
@ -73,7 +72,7 @@ where
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn context(self, context: impl IntoContext) -> Self::Output {
|
fn context(self, context: impl IntoContext) -> Self::Output {
|
||||||
How::new(Context::new(Detail::Error(PrivateError(self))))
|
How::new(self.into_context())
|
||||||
.context(context)
|
.context(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue