Crate failure

source ·
Expand description

An experimental new error-handling library. Guide-style introduction is available here.

The primary items exported by this library are:

  • Fail: a new trait for custom error types in Rust.
  • Error: a wrapper around Fail types to make it easy to coalesce them at higher levels.

As a general rule, library authors should create their own error types and implement Fail for them, whereas application authors should primarily deal with the Error type. There are exceptions to this rule, though, in both directions, and users should do whatever seems most appropriate to their situation.


Backtraces are disabled by default. To turn backtraces on, enable the backtrace Cargo feature and set the RUST_BACKTRACE environment variable to a non-zero value (this also enables backtraces for panics). Use the RUST_FAILURE_BACKTRACE variable to enable or disable backtraces for failure specifically.


Exits a function early with an Error.
Exits a function early with an Error if the condition is not satisfied.
Constructs an Error using the standard string interpolation syntax.


A Backtrace.
A iterator over the causes of a Fail
A compatibility wrapper around an error type from this crate.
An error with context around it.
The Error type, which can contain any failure.
Wrapper for std errors to make them Sync.


The AsFail trait
The Fail trait.
Extension methods for Result.


Constructs a Fail type from a string.

Type Definitions

A common result with an Error.