soph_core/traits/
error.rspub trait ErrorTrait {
fn boxed<E>(error: E) -> crate::BoxError
where
E: std::error::Error + Send + Sync + 'static,
{
Box::new(error)
}
#[cfg(feature = "anyhow")]
fn anyhow<E>(error: E) -> anyhow::Error
where
E: std::error::Error + Send + Sync + 'static,
{
anyhow::Error::new(error)
}
#[cfg(feature = "eyre")]
fn eyre<E>(error: E) -> eyre::Report
where
E: std::error::Error + Send + Sync + 'static,
{
eyre::Report::new(error)
}
fn wrap<E>(error: E) -> crate::AnyError
where
E: std::error::Error + Send + Sync + 'static,
{
cfg_if::cfg_if! {
if #[cfg(feature = "eyre")]{
eyre::Report::new(error)
}else if #[cfg(feature = "anyhow")]{
anyhow::Error::new(error)
}else{
Box::new(error)
}
}
}
}