Releases: SierraSoftworks/human-errors-rs
Version 0.2.3
Changes
- feat: Added support for
Option::or_user_err(msg, advice)andOption::or_system_err(msg, advice)helpers. - refactor: Moving to
Result::or_user_err(...)andResult::wrap_user_err(...)instead of the originalResult::map_err_as_user(...)andResult::wrap_err_as_user(...)methods (and same for thesystemvariants). - refactor: Removed default implementations of
Into<human_errors::Error>for various stdlib errors (they were limited in coverage and usefullness, and this pattern has been largely replaced with the move to 0.2.x). - build(deps): Update colored requirement from 2.0 to 3.0 @dependabot[bot] (#34)
Version 0.2.2
What's Changed
This release adds support for the new pretty feature, which enables you to render a lovely human-readable version of the error for your users.
eprintln!("{}", human_errors::pretty(&your_error));
- build(deps): Bump actions/upload-artifact from 5 to 6 by @dependabot[bot] in #31
- build(deps): Bump actions/download-artifact from 6.0.0 to 7.0.0 by @dependabot[bot] in #32
- feat: Add support for pretty CLI rendering of errors by @notheotherben in #33
Full Changelog: v0.2.1...v0.2.2
Version 0.2.1
Changes
- Improved handling for advice (ensuring that only non-duplicate entries are shown).
- Improved Debug representation for wrapped errors (using a more descriptive struct name).
Version 0.2.0
The major difference here is a shift away from using a custom error type (generated using the error_shim!(...) macro in v0.1) to instead using a standard error type with better support for providing additional advice, and improved interoperability with the standard library's Error type. We've also shifted from using impl From<E> for MyErrorType as the primary means of wrapping errors to instead providing extensions for Results<T, E> which simplify wrapping errors with contextual advice (a pattern which was used extensively within codebases implementing human_errors).
What's Changed
- refactor: Redesign how we handle errors, enabling richer advice and easier extensibility by @notheotherben in #30
Before
use human_errors;
use std::fs;
human_errors::error_shim!(MyError);
fn read_config() -> Result<String, MyError> {
fs::read_to_string("config.toml").map_err(|err| {
user_with_internal(
"We could not read the configuration file.",
"Make sure that you've specified a valid config file with the --config option.",
err
)
})
}After
use human_errors::ResultExt;
use std::fs;
fn read_config() -> Result<String, human_errors::Error> {
fs::read_to_string("config.toml").wrap_err_as_user(
"We could not read the configuration file.",
&["Make sure that you've specified a valid config file with the --config option."])
}Migration Instructions
- Remove any
human_errors::error_shim!(MyErrorType)usage and replace all usage ofMyErrorTypewithhuman_errors::Error. - Replace any calls to
human_errors::description(msg)withmsg)(conversion happens automatically). - Replace any calls to
human_errors::user(msg, advice)withhuman_errors::user(msg, &[advice]). - Replace any calls to
human_errors::system(msg, advice)withhuman_errors::system(msg, &[advice]). - Replace any calls to
human_errors::user_with_internal(msg, advice, err)withhuman_errors::wrap_user(err, msg, &[advice]). - Replace any calls to
human_errors::system_with_internal(msg, advice, err)withhuman_errors::wrap_system(err, msg, &[advice]). - Replace code using the
.map_err(|e| human_errors::user_with_internal(msg, advice, e))pattern with.wrap_err_as_user(msg, &[advice]). - Replace code using the
.map_err(|e| human_errors::system_with_internal(msg, advice, e))pattern with.wrap_err_as_system(msg, &[advice]).
Removed Functionality
- We no longer support implementing custom
From<T>conversions, instead you should wrap errors in contextual advice using any of theuser,system,wrap_user, andwrap_systemmethods. - We no longer provide the ability to generate dynamic advice at runtime, relying on
&'static [&'static str]advice lists for performance reasons. Instead, you can incorporate any dynamic context into the error message using thewrap_user(...)andwrap_system(...)methods.
Full Changelog: v0.1.7...v0.2.0
Version 0.1.6
Changes
- ci: Fix rust code coverage collection @notheotherben (#16)
- build(deps): Bump release-drafter/release-drafter from 6.0.0 to 6.1.0 @dependabot[bot] (#11)
- build(deps): Bump codecov/codecov-action from 5.1.2 to 5.3.1 @dependabot[bot] (#14)
- build(deps): Bump actions/download-artifact from 4.1.8 to 4.1.9 @dependabot[bot] (#15)
- build(deps): Bump codecov/codecov-action from 5.1.1 to 5.1.2 @dependabot[bot] (#10)
- build(deps): Bump release-drafter/release-drafter from 5.14.0 to 6.0.0 @dependabot[bot] (#9)
Version 0.1.5
Changes
- ci: Fix package versioning logic for releases @notheotherben (#8)
Version 0.1.4
Changes
- build(deps): Bump actions/download-artifact from 4.1.7 to 4.1.8 @dependabot (#3)
- build(deps): Bump Swatinem/rust-cache from 1 to 2 @dependabot (#4)
- build(deps): Bump actions/upload-artifact from 2 to 4 @dependabot (#5)
- build(deps): Bump actions/checkout from 1 to 4 @dependabot (#7)
- build(deps): Bump codecov/codecov-action from 1.2.1 to 5.1.1 @dependabot (#6)
- feat: Add support for recursively resolving standard error causes @notheotherben (#2)
- build(deps): Bump actions/download-artifact from 2 to 4.1.7 in /.github/workflows @dependabot (#1)
Version 0.1.3
Changes
- Fixes the generation of advice when empty strings are provided
- Addresses a
clippywarning caused by the use ofIntoinstead ofFromfor the extend macro.
Version 0.1.2
Changes
- Improved documentation to avoid failing tests in derived libraries.
Version 0.1.1
Changes
- feat: Added a macro to expose a custom
human_errors::Errortype in your module for extension withFrom<T>andInto<T>if you need it.