Skip to content

Releases: SierraSoftworks/human-errors-rs

Version 0.2.3

02 Jan 23:09
677dd47

Choose a tag to compare

Changes

  • feat: Added support for Option::or_user_err(msg, advice) and Option::or_system_err(msg, advice) helpers.
  • refactor: Moving to Result::or_user_err(...) and Result::wrap_user_err(...) instead of the original Result::map_err_as_user(...) and Result::wrap_err_as_user(...) methods (and same for the system variants).
  • 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

23 Dec 13:07
1a0263e

Choose a tag to compare

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));
image
  • 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

03 Dec 15:21
f327cee

Choose a tag to compare

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

03 Dec 13:46
f2cf0ee

Choose a tag to compare

⚠️ This is a major breaking change which will require you to rewrite your code if you chose to adopt it (we will continue to maintain the v0.1.x branch which offers a different approach to this problem).

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

  1. Remove any human_errors::error_shim!(MyErrorType) usage and replace all usage of MyErrorType with human_errors::Error.
  2. Replace any calls to human_errors::description(msg) with msg) (conversion happens automatically).
  3. Replace any calls to human_errors::user(msg, advice) with human_errors::user(msg, &[advice]).
  4. Replace any calls to human_errors::system(msg, advice) with human_errors::system(msg, &[advice]).
  5. Replace any calls to human_errors::user_with_internal(msg, advice, err) with human_errors::wrap_user(err, msg, &[advice]).
  6. Replace any calls to human_errors::system_with_internal(msg, advice, err) with human_errors::wrap_system(err, msg, &[advice]).
  7. Replace code using the .map_err(|e| human_errors::user_with_internal(msg, advice, e)) pattern with .wrap_err_as_user(msg, &[advice]).
  8. 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 the user, system, wrap_user, and wrap_system methods.
  • 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 the wrap_user(...) and wrap_system(...) methods.

Full Changelog: v0.1.7...v0.2.0

Version 0.1.6

26 Feb 22:34
4b8469c

Choose a tag to compare

Changes

Version 0.1.5

10 Dec 00:49
d42472a

Choose a tag to compare

Changes

Version 0.1.4

10 Dec 00:42
85ae22d

Choose a tag to compare

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

01 May 14:37
5ae0adf

Choose a tag to compare

Changes

  • Fixes the generation of advice when empty strings are provided
  • Addresses a clippy warning caused by the use of Into instead of From for the extend macro.

Version 0.1.2

13 Nov 15:58

Choose a tag to compare

Changes

  • Improved documentation to avoid failing tests in derived libraries.

Version 0.1.1

22 Feb 11:22
98cf81e

Choose a tag to compare

Changes

  • feat: Added a macro to expose a custom human_errors::Error type in your module for extension with From<T> and Into<T> if you need it.