https://github.com/killercup/snafu-cli-debug
Implement Rust's Debug trait on Snafu errors for pretty CLI output
https://github.com/killercup/snafu-cli-debug
Last synced: 8 months ago
JSON representation
Implement Rust's Debug trait on Snafu errors for pretty CLI output
- Host: GitHub
- URL: https://github.com/killercup/snafu-cli-debug
- Owner: killercup
- License: apache-2.0
- Created: 2019-07-08T13:43:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-03T17:56:57.000Z (over 6 years ago)
- Last Synced: 2025-04-04T12:11:37.856Z (12 months ago)
- Language: Rust
- Size: 13.7 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Derive Debug implementation on Snafu Errors that make pretty output
## What
The challenge: Error handling in Rust.
The approach: Embrace `Result`s!
The problem: It's not easy to give add nice contexts to errors.
The solution: [Snafu](https://docs.rs/snafu)!
The challenge: Printing errors in CLI apps.
The approach: Embrace `fn main() -> Result<(), Error>`!
The problem: It prints using `Debug`, i.e., like `println!("{:?}", error)`.
The solution: This crate!
## Usage
See example.
## Output
```console
$ cargo run --example simple -q -- foo
Error: Can't read file `foo`
cause: No such file or directory (os error 2)
```
```console
$ cargo run --example simple -q -- foo
Error: Can't read file `foo`
cause: No such file or directory (os error 2)
```
## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.