cgp_error/traits/
has_error_type.rs

1use core::fmt::Debug;
2
3use cgp_component::{DelegateComponent, HasComponents, WithProvider};
4use cgp_component_macro::cgp_type;
5use cgp_type::{ProvideType, UseType};
6
7cgp_type! {
8    /**
9        This is used for contexts to declare that they have a _unique_ `Self::Error` type.
10
11        Although it is possible for each context to declare their own associated
12        `Error` type, doing so may result in having multiple ambiguous `Self::Error` types,
13        if there are multiple associated types with the same name in different traits.
14
15        As a result, it is better for context traits to include `HasError` as their
16        parent traits, so that multiple traits can all refer to the same abstract
17        `Self::Error` type.
18
19       The `Error` associated type is also required to implement [`Debug`].
20       This is to allow `Self::Error` to be used in calls like `.unwrap()`,
21       as well as for simpler error logging.
22
23       More details about how to use `HasErrorType` is available at
24       <https://patterns.contextgeneric.dev/error-handling.html>
25    */
26    Error: Debug
27}