93dba898c2
The errors returned from various lock time functions had several issues. Among the obvious - `Error` being returned from all operations even when some of its variants were unreachable, there were subtle issues around error messages: * `ParseIntError` didn't contain information whether the parsed object is `Height` or `Time`. * Logically overflow and out-of-bounds should be the same thing but produced different error messages. * Mentioning integers is too technical for a user, talking about upper and lower bound is easier to understand. * When minus sign is present `std` reports it as invalid digit which is less helpful than saying negative numbers are not allowed. It is also possible that `ParseIntError` will need to be removed from public API during crate smashing or stabilization, so avoiding it may be better. This commit significantly refactors the errors. It adds separate types for parsing `Height` and `Time`. Notice that we don't compose them from `ParseIntError` and `ConversionError` - that's not helpful because they carry information that wouldn't be used when displaying which is wasteful. Keeping errors small can be important. It's also worth noting that exposing the inner representation could cause confusion since the same thing: out of bounds can be represented as an overflow or as a conversion error. So for now we conservatively hide the details and even pretend there's no `source` in case of overflow. This can be expanded in the future if needed. The returned errors are now minimal. `LockTime` parsing errors are currentlly unchanged. |
||
---|---|---|
.. | ||
contrib | ||
embedded | ||
examples | ||
src | ||
tests | ||
CHANGELOG.md | ||
Cargo.toml | ||
build.rs |