# Module std::error [−] [src]

Traits for working with Errors.

# The `Error` trait

`Error` is a trait representing the basic expectations for error values, i.e. values of type `E` in `Result<T, E>`. At a minimum, errors must provide a description, but they may optionally provide additional detail (via `Display`) and cause chain information:

fn main() { use std::fmt::Display; trait Error: Display { fn description(&self) -> &str; fn cause(&self) -> Option<&Error> { None } } }

    use std::fmt::Display;

    trait Error: Display {
        fn description(&self) -> &str;

        fn cause(&self) -> Option<&Error> { None }
    }

The `cause` method is generally used when errors cross "abstraction boundaries", i.e. when a one module must report an error that is "caused" by an error from a lower-level module. This setup makes it possible for the high-level module to provide its own errors that do not commit to any particular implementation, but also reveal some of its implementation for debugging via `cause` chains.

## Traits

Error | Base functionality for all errors in Rust.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)