cgp_error/traits/
can_raise_error.rs

1use cgp_component::{DelegateComponent, HasCgpProvider, IsProviderFor, UseContext, UseDelegate};
2use cgp_macro::cgp_component;
3
4use crate::traits::has_error_type::HasErrorType;
5
6/**
7   Used for injecting external error types into [`Self::Error`](HasErrorType::Error).
8
9   As an example, if `Context: CanRaiseError<ParseIntError>`, then we would be
10   able to call `Context::raise_error(err)` for an error value
11   [`err: ParseIntError`](core::num::ParseIntError) and get back
12   a [`Context::Error`](HasErrorType::Error) value.
13*/
14#[cgp_component {
15    provider: ErrorRaiser,
16    derive_delegate: UseDelegate<SourceError>,
17}]
18pub trait CanRaiseError<SourceError>: HasErrorType {
19    fn raise_error(error: SourceError) -> Self::Error;
20}