hermes_error/handlers/
report.rs1use alloc::sync::Arc;
2
3use cgp::core::error::{ErrorRaiser, HasErrorType};
4use eyre::Report;
5
6use crate::types::{Error, ErrorDetail};
7
8pub struct ReportErrorWithRetry<const RETRYABLE: bool>;
9
10pub type ReportRetryableError = ReportErrorWithRetry<true>;
11pub type ReportError = ReportErrorWithRetry<false>;
12
13impl<Context, E, const RETRYABLE: bool> ErrorRaiser<Context, E> for ReportErrorWithRetry<RETRYABLE>
14where
15 Context: HasErrorType<Error = Error>,
16 Report: From<E>,
17{
18 fn raise_error(e: E) -> Error {
19 Error {
20 is_retryable: RETRYABLE,
21 detail: ErrorDetail::Report(Arc::new(e.into())),
22 }
23 }
24}