Skip to content

Releases: mcmah309/error_set

v0.8.4

28 Dec 17:46
Compare
Choose a tag to compare
  • Deprecate ResultContext and OptionContext in favor of ErrContext and NoneContext for feature flags
    • Break feature out into separate crate err_trail that can be used independent of error_set
  • fix: changed all_cfg_attributes to a HashSet ... by @lanastara in #25
  • Improve error messages for invalid syntax
  • Support nested generics

New Contributors

Full Changelog: v0.8.3...v0.8.4

v0.8.3

17 Dec 21:45
Compare
Choose a tag to compare

Error variants and related generated code now respect #![cfg] blocks

error_set::error_set! {
    CacheError={
        File(backend_file::Error),
        #[cfg(feature="backend-sqlite")]
        Sqlite(backend_sqlite::Error),
    };
}

v0.8.1

05 Dec 18:28
Compare
Choose a tag to compare

Selective Disables For From

From now accepts arguments to only disable certain From implementations. e.g.

error_set! {
    U = {
        IoError(std::io::Error),
    };
    V = {
        FmtError(std::fmt::Error),
        IoError(std::io::Error),
    };
    #[disable(From(std::io::Error, U))]
    W = V || U;
}

Full Changelog: v0.8...v0.8.1

v0.8.0

05 Dec 16:56
Compare
Choose a tag to compare

Generics

error_set now supports generics. e.g.

error_set! {
    X<G: Debug> = {
        A {
            a: G
        }
    };
    Y<H: Debug> = {
        B {
            b: H
        }
    };
    Z<T: Debug> = X<T> || Y<T>;
}

In Z<T: Debug> = X<T> || Y<T>; T will replace G in X - X<T: Debug>. Thus this statement is the
same as writing

error_set! {
    ...

    Z<T: Debug> = {
        A {
            a: T
        },
        B {
            b: T
        }
    };
}

Disable

error_set auto-implements From, Display, Debug, and Error for the set. If it is ever desired to disable
this. Add #[disable(..)] to the set. e.g.

error_set! {
    #[disable(Display,Debug)]
    X = {
        A,
    };
}

impl Display for X {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "X")
    }
}

impl Debug for X {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "X")
    }
}

Breaking

If two variants share the same source, the From implementation will not automatically be generated.

Full Changelog: v0.7.0...v0.8.0

v0.7.0

30 Oct 03:52
Compare
Choose a tag to compare
  • Multiple source variants of the same type are now supported. See here for more.
error_set! {
    ErrorEnum = {
        IoError(std::io::Error),
        IoError2(std::io::Error),
    };
}
  • Source struct variants are now supported. See here for more.
error_set! {
    ErrorEnum = {
        IoError(std::io::Error) {
            field1: String,
            field2: &'static str,
        }
    };
}
  • coerce_macro feature removed.

Full Changelog: v0.6.6...v0.7.0

v0.6.6

28 Oct 14:43
Compare
Choose a tag to compare
  • Support parsing more/all types for inline struct fields
&'static str
(u32, String)

etc.

v0.6.5

28 Oct 06:50
Compare
Choose a tag to compare
  • Display messages now support inline interpolation
// Shorthand for `#[display("User `{}` with role `{}` does not exist", name, role)]`
#[display("User `{name}` with role `{role}` does not exist")] 
  • Remove dyn-fmt dependency

Full Changelog: v0.6.4...v0.6.5

v0.6.4

18 Oct 04:11
Compare
Choose a tag to compare
  • #![no_std] display messages can now refer to fields

Full Changelog: v0.6.3...v0.6.4

v0.6.3

18 Oct 02:44
Compare
Choose a tag to compare
  • Support display for wrapped errors #8 (thanks @duskmoon314)
  • Wrapped errors delegate display to the inner error by default

Full Changelog: v0.6.0...v0.6.3

v0.6.0

18 Sep 08:15
Compare
Choose a tag to compare
  • Support logging on #![no_std] with the dfmt feature flag
  • Remove swallow logging methods
  • Refactor logging traits
  • Add ConsumeDisplay trait
  • Change the format of the coerce! macro
    old
    let val = coerce!(setx => {
                Ok(val) => val,
                Err(SetX::X) => {}, // handle disjointedness
                { Err(SetX) => return Err(SetY) } // terminal coercion
            })?;
    new
    let val = coerce!{ setx,
                Ok(val) => val,
                Err(SetX::X) => {}, // handle disjointedness
                { Err(SetX) => return Err(SetY) } // terminal coercion
            }?;

Full Changelog: v0.5.4...v0.6.0