improvement: make diagnostics for flags involving byte count parsing actually good

This adds an error type called `ByteCountParseError` with a vanilla
`std::error::Error` implementation. The code could be significantly
compressed with a dependency like `thiserror`.

I opted to implement a separate error type for `parse_byte_count` rather
than using `anyhow`'s small ecosystem of error types there (though they
are used in `<binary>::run`) because it allows pairing diagnostic
results with tests, incl. those already written. This can be helpful in
preventing regressions in error diagnostics.
This commit is contained in:
Erich Gubler authored and David Peter committed 2020-06-17 18:05:42 +02:00
1 parent e0da7b3f82
commit 13aec946a3
3 files changed
+217 -66

No files matched your search

+1
View File
@@ -15,6 +15,7 @@ ansi_term = "0.12"
anyhow = "1.0.31"
atty = "0.2"
libc = "0.2"
thiserror = "1.0.19"
[dependencies.clap]
version = "2"