Skip to main content

TrivialError

Trait TrivialError 

Source
pub trait TrivialError: Error {
    // Required methods
    fn new(error_kind: Self::Kind) -> Self;
    fn with_description<S>(error_kind: Self::Kind, description: S) -> Self
       where S: StaticString;
}
Expand description

An error that is able to be constructed trivially from an ErrorKind.

This trait powers the err! macro, allowing you to use type inference to construct an error based solely on a provided ErrorKind.

It’s usually implemented for you by the Error derive macro. But there are times when the derive macro cannot automatically implement this.

See the Error trait documentation for more information.

Required Methods§

Source

fn new(error_kind: Self::Kind) -> Self

Construct a new error with the provided error_kind.

Source

fn with_description<S>(error_kind: Self::Kind, description: S) -> Self
where S: StaticString,

Construct a new error with the provided error_kind and description.

The description will only be captured if your error type is configured to collect description information. See envelopes for more details.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§