Derive Macro ApplicationError

Source
#[derive(ApplicationError)]
{
    // Attributes available to this derive:
    #[stop_sentinel]
    #[stop_sentinel_with_event]
    #[database_error]
    #[crates]
}
Expand description

Define a Application Error type that can be used in the event-driven-library.

Before deriving this, you must impl Debugtraits.

This macro can be only used in enum.

§Attributes

  • #[crates(...)] - Specify the name of root of event-driven-library crate. (Default is event_driven_library)
  • #[stop_sentinel] - Specify the error matching for BaseError::StopSentinel.
  • #[stop_sentinel_with_event] - Specify the error matching for BaseError::StopSentinelWithEvent.
  • #[database_error] - Specify the error matching for BaseError::DatabaseError.

§Example

#[derive(Debug, ApplicationError)]
#[crates(crate::imports::event_driven_library)]
enum TestError {
  #[stop_sentinel]
  Stop,
  #[stop_sentinel_with_event]
  StopWithEvent(Box<AnyError>),
  #[database_error]
  DatabaseError(Box<AnyError>),
}