Skip to main content

hermes_error/handlers/
debug.rs

1use alloc::sync::Arc;
2use core::fmt::Debug;
3
4use cgp::core::error::{ErrorRaiser, HasErrorType};
5use eyre::eyre;
6
7use crate::types::{Error, ErrorDetail};
8
9pub struct DebugErrorWithRetry<const RETRYABLE: bool>;
10
11pub type DebugRetryableError = DebugErrorWithRetry<true>;
12pub type DebugError = DebugErrorWithRetry<false>;
13
14impl<Context, E, const RETRYABLE: bool> ErrorRaiser<Context, E> for DebugErrorWithRetry<RETRYABLE>
15where
16    Context: HasErrorType<Error = Error>,
17    E: Debug,
18{
19    fn raise_error(e: E) -> Error {
20        Error {
21            is_retryable: RETRYABLE,
22            detail: ErrorDetail::Report(Arc::new(eyre!("{:?}", e))),
23        }
24    }
25}