Skip to main content

ErrorCompat

Trait ErrorCompat 

Source
pub trait ErrorCompat {
    // Provided methods
    fn backtrace(&self) -> Option<&Backtrace> { ... }
    fn iter_chain(&self) -> ChainCompat<'_, '_> 
       where Self: AsErrorSource { ... }
}
Expand description

Backports changes to the Error trait to versions of Rust lacking them.

It is recommended to always call these methods explicitly so that it is easy to replace usages of this trait when you start supporting a newer version of Rust.

ErrorCompat::backtrace(&error); // Recommended
error.backtrace();              // Discouraged

Provided Methods§

Source

fn backtrace(&self) -> Option<&Backtrace>

Returns a Backtrace that may be printed.

Source

fn iter_chain(&self) -> ChainCompat<'_, '_>
where Self: AsErrorSource,

Returns an iterator for traversing the chain of errors, starting with the current error and continuing with recursive calls to Error::source.

To omit the current error and only traverse its sources, use skip(1).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<'a, E> ErrorCompat for &'a E
where E: ErrorCompat,

Source§

impl<E> ErrorCompat for Box<E>
where E: ErrorCompat,

Available on crate features alloc only.

Implementors§

Source§

impl ErrorCompat for ConfigFileError

Available on crate feature guide only.
Source§

impl ErrorCompat for snafu::guide::examples::backtrace::Error

Available on crate feature guide only.
Source§

impl ErrorCompat for snafu::guide::examples::basic::Error

Available on crate feature guide only.
Source§

impl ErrorCompat for Whatever

Available on crate features alloc only.
Source§

impl ErrorCompat for WhateverLocal

Available on crate features alloc only.