hermes_cli/impls/
error.rs

1use core::convert::Infallible;
2
3use cgp::core::error::{
4    DelegateErrorRaiser, ErrorRaiser, ErrorRaiserComponent, ErrorTypeComponent,
5};
6use cgp::prelude::*;
7use eyre::Report;
8use hermes_error::handlers::display::DisplayError;
9use hermes_error::handlers::identity::ReturnError;
10use hermes_error::handlers::infallible::HandleInfallible;
11use hermes_error::handlers::report::ReportError;
12use hermes_error::handlers::wrap::WrapErrorDetail;
13use hermes_error::impls::ProvideHermesError;
14use hermes_error::traits::wrap::WrapError;
15use hermes_error::types::Error;
16use hermes_relayer_components::error::traits::retry::RetryableErrorComponent;
17use hermes_runtime::types::error::TokioRuntimeError;
18use ibc_relayer_types::core::ics02_client::error::Error as Ics02Error;
19use ibc_relayer_types::core::ics02_client::height::HeightError;
20use ibc_relayer_types::core::ics03_connection::error::Error as Ics03Error;
21use ibc_relayer_types::core::ics23_commitment::error::Error as Ics23Error;
22use ibc_relayer_types::core::ics24_host::error::ValidationError as Ics24ValidationError;
23
24pub struct ProvideCliError;
25
26pub struct CliErrorHandlers;
27
28pub trait CanHandleCliError<Context>: ErrorRaiser<Context, TokioRuntimeError>
29where
30    Context: HasErrorType<Error = Error>,
31{
32}
33
34impl<Context> CanHandleCliError<Context> for ProvideCliError where
35    Context: HasErrorType<Error = Error>
36{
37}
38
39delegate_components! {
40    ProvideCliError {
41        [
42            ErrorTypeComponent,
43            RetryableErrorComponent,
44        ]: ProvideHermesError,
45        ErrorRaiserComponent: DelegateErrorRaiser<CliErrorHandlers>,
46    }
47}
48
49delegate_components! {
50    CliErrorHandlers {
51        Error: ReturnError,
52        Infallible: HandleInfallible,
53        [
54            Report,
55            TokioRuntimeError,
56            toml::de::Error,
57            toml::ser::Error,
58            HeightError,
59            Ics02Error,
60            Ics03Error,
61            Ics23Error,
62            Ics24ValidationError,
63        ]: ReportError,
64        [
65            <'a> &'a str,
66            String,
67        ]:
68            DisplayError,
69        [
70            WrapError<&'static str, Error>,
71            WrapError<String, Error>,
72        ]:
73            WrapErrorDetail,
74    }
75}