Skip to main content

hermes_error/handlers/
wrap.rs

1use alloc::format;
2use alloc::sync::Arc;
3use core::fmt::Debug;
4
5use cgp::core::error::{ErrorRaiser, HasErrorType};
6
7use crate::traits::wrap::WrapError;
8use crate::types::{Error, ErrorDetail};
9
10pub struct WrapErrorDetail;
11
12impl<Context, Detail> ErrorRaiser<Context, WrapError<Detail, Error>> for WrapErrorDetail
13where
14    Context: HasErrorType<Error = Error>,
15    Detail: Debug,
16{
17    fn raise_error(WrapError { detail, error }: WrapError<Detail, Error>) -> Error {
18        Error {
19            is_retryable: error.is_retryable,
20            detail: ErrorDetail::Wrapped(format!("{:?}", detail), Arc::new(error.detail)),
21        }
22    }
23}