Skip to content

Conversation

@LuisFerLCC
Copy link
Owner

error-stack-macros2 v0.1.0

The very first development version of error-stack-macros2 is finally here!

Features

This version (0.1.0) offers a derive macro for the Error trait which encourages the best practices for defining error-stack context types.

Here's an example. This code:

use std::{
    error::Error,
    fmt::{self, Display, Formatter},
};

#[derive(Debug)]
pub enum CreditCardError {
    InvalidInput(String),
    Other,
}

impl Display for CreditCardError {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        let msg = match self {
            Self::InvalidInput(_) => "credit card not found",
            Self::Other => "failed to retrieve credit card",
        };

        f.write_str(msg)
    }
}

impl Error for CreditCardError {}

...can now be reduced to this code:

use error_stack_macros2::Error;

#[derive(Debug, Error)]
pub enum CreditCardError {
    #[display("credit card not found")]
    InvalidInput(String),

    #[display("failed to retrieve credit card")]
    Other,
}

This new release also means that we will now be listening to feedback and accepting new features (macros, obviously). We are also now committed to maintaining this macro going forward and keeping our dependencies up to date.

Previous release notes

If you want to take a look at the notes from previous releases, go to GitHub Releases.

@LuisFerLCC LuisFerLCC added this to the v0.1.0 milestone Sep 22, 2025
@LuisFerLCC LuisFerLCC self-assigned this Sep 22, 2025
@LuisFerLCC LuisFerLCC added the 🔄 New release This PR into `stable` marks a new release label Sep 22, 2025
@LuisFerLCC LuisFerLCC merged commit 2d864eb into stable Sep 22, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔄 New release This PR into `stable` marks a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants