Crates.io | errors |
lib.rs | errors |
version | 0.1.0 |
created_at | 2019-05-01 06:00:05.662074+00 |
updated_at | 2025-08-18 13:14:22.949056+00 |
description | std::error::Error utilities |
homepage | |
repository | https://github.com/seanmonstar/errors |
max_upload_size | |
id | 131314 |
size | 30,503 |
std::error::Error
extensions
This crate encourages usage of the std::error::Error
trait for
describing errors, providing the following utilities:
errors::new
, errors::wrap
,
and errors::opaque
functions ease the creation of simple
error values.errors::iter
iterators to find the error you're looking for.errors::fmt
adapter allows
foreign error values to follow along.An Error
likely has a message, it might have a cause, and someday, it may
have a backtrace. How can a user decide how they should be formatted?
Top message only
ship exploded
Top message + message of source chain
ship exploded: cat hair in generator
Top message + message of source chain + trace/frame
ship exploded
at main.rs:55
at ship.rs:89
Caused by: cat hair in generator
at ship::parts::generator.rs:33
at ship::parts::engine.rs:789
at ship.rs:89
at main.rs:55
{}
): Print only the top-level message. This is inline with the recommendation for Error
println!("top only = {}", err)
outputs top only = ship exploded
.println!("top only: {:.0}", err)
.{:+}
): Prints the message, and the message of each source, joined by ": "
.
println!("chain = {:+}", err)
outputs chain = ship exploded: cat hair in generator
.{:#}
): Prints the message and stack trace/frame
println!("top trace = {:#}", err)
outputs top trace = ship exploded\n at ship.rs:89
.{:+#}
): Prints the message and stack trace/frame, and message and trace for each source, joined by \nCaused by:
.{:+.2}
): Sets the maximum messages that should be printed down the source chain.