Skip to content

Add expression macro for ad-hoc error construction (anyhow! parity) #444

Description

@RAprogramm

anyhow 1.x provides the anyhow! macro that builds an error value as an expression from a format string, an existing error, or both. masterror only exposes statement-form macros (ensure!, fail!).

Add an expression macro (e.g. error!(AppErrorKind::Validation, "bad input: {value}")) that constructs an AppError inline, supporting:

  • format-string interpolation (implicit captures like format!)
  • wrapping an existing impl Error + Send + Sync value
  • optional AppCode/kind selection with a sensible default

This closes the last ergonomic gap with anyhow for application code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions