[−][src]Trait evitable::ErrorContext
Error context trait, typically used with #[derive(ErrorContext)]
.
This produces Error and ErrorKind types for the given context.
Associated Types
type Kind: EvitableErrorKind
Associated error kind enum.
type Error: EvitableError<Context = Self, Kind = Self::Kind>
Associated error struct.
Required methods
fn kind(&self) -> Self::Kind
Get the error kind.
Example
#[derive(ErrorContext)] pub enum Context { #[evitable(description("Io error ({})", 0))] Io(u8), #[evitable(description = "Fmt error")] Fmt, } // Later let error = Context::Io(42); let t = match error.kind() { evitable_context::ErrorKind::Io => "Io", evitable_context::ErrorKind::Fmt => "Fmt", _ => "Other", }; assert_eq!(t, "Io");