[−][src]Trait evitable::ErrorContext
Error context trait, typically used with #[evitable]
.
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
#[evitable] 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");
Provided methods
fn into_error<S: StdError + Send + Sync + 'static>(
self,
source: S
) -> Self::Error
self,
source: S
) -> Self::Error