1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/// A vendored error type providing the Debug format from `anyhow::Error`.
///
/// This error type is meant to be used in one place in your binary: the error
/// type of the `Result` your `main` function returns. This converts any error
/// your `main` function produces into a `little_anyhow::Error`, which provides
/// human-readable error messages for your users.
///
/// Error messages look like:
///
/// ```ignore
/// Error: error reading `Blocks.txt`
///
/// Caused by:
/// 0: invalid Blocks.txt data on line 223
/// 1: one end of range is not a valid hexidecimal integer
/// 2: invalid digit found in string
/// ```
///
/// For more information, see:
///
/// - [Modular Errors in Rust]
/// - [little-anyhow]
///
/// [modular errors in rust]: https://sabrinajewson.org/blog/errors#guidelines-for-good-errors
/// [little-anyhow]: https://github.com/EricCrosson/little-anyhow
///
/// # Examples
///
/// ```should_panic
/// use std::io::{self, Write};
///
/// // Return `Result<(), little_anyhow::Error>` from `main` for
/// // human-readable errors from your binary
/// fn main() -> Result<(), little_anyhow::Error> {
/// writeln!(
/// io::stdout(),
/// "You can create a little_anyhow::Error from any type implementing `std::error::Error`"
/// )?;
///
/// let simulated_error = std::fmt::Error; // an easy-to-create error type
/// Err(simulated_error)?
/// }
/// ```
;