1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use std::error::Error as StdError;

use cgp_core::error::{ErrorRaiser, ProvideErrorType};
use cgp_core::prelude::*;

pub type Error = Box<dyn StdError + Send + Sync + 'static>;

pub struct HandleErrorsWithStdError;

impl<Context> ProvideErrorType<Context> for HandleErrorsWithStdError
where
    Context: Async,
{
    type Error = Error;
}

impl<Context, E> ErrorRaiser<Context, E> for HandleErrorsWithStdError
where
    Context: HasErrorType<Error = Error>,
    E: StdError + Send + Sync + 'static,
{
    fn raise_error(e: E) -> Error {
        e.into()
    }
}