The easiest and most intuitive error handling solution.
| Docs |
First, You should make your own an error set.
rust
err! {
BrokenHeader => "broken header."
AnotherHeader => "not matched header."
FileNotFound => "file not found."
EmptyArgument => "empty argument."
UnexpectedEof => "unexpected eof."
OutOfBounds => "index out of bounds."
NotMatched => "btw not matched."
}
And just errbang!
rust
errbang!(err:BrokenHeader)
```rust
fn foo() -> Result
fn main() -> Result<()> {
let isbar_zero = foo()?;
}
rust
errbang!(err::MyError1);
errbang!(err::MyError2, "cannot find.");
errbang!(err::MyError3, "{} is {}", "bar", 2);
```