An error handling library for portable unrecoverable errors.
This crate provides,
Failure
struct that represents an unrecoverable error with an error message and user-level backtrace
u32
, String
, and Vec
of those)serde
support ("serde" feature)std::error::Error
traitOrFail
trait
Failure
each time when calling OrFail::or_fail()
bool
, Option<_>
and Result<_, _>
implement OrFail
```rust use orfail::{OrFail, Result};
fn checknonzero(n: isize) -> Result<()> { (n != 0).or_fail()?; Ok(()) }
fn safediv(x: isize, y: isize) -> Result
// OK asserteq!(safediv(4, 2), Ok(2));
// NG
asserteq!(safediv(4, 0).err().map(|e| e.tostring()),
Some(
r#"expected true
but got false
at src/lib.rs:8
at src/lib.rs:13
"#.toowned()));
```