miette icon indicating copy to clipboard operation
miette copied to clipboard

Feature Request: Support `ensure!` without error message like anyhow.

Open oxcrow opened this issue 9 months ago • 0 comments

Hello,

Would it be possible to allow the use of ensure! macro without an error message.

Sometimes I just want to write the assertion test without worrying about creating a pretty error message.

There are many instances where it is preferable to not provide an error message with ensure!.

  • While debugging something and writing quick tests for it.
  • While writing assertions.
  • While writing unit tests.
  • etc.

It would help if that was supported by miette.

Anyhow supports this feature.

The code would look like...

macro_rules! ensure {
  ($condition: expr) => {
       miette::ensure!($condition, "ensure failed");
  }
}

Thank you ~ oxcrow

oxcrow avatar Apr 11 '25 22:04 oxcrow