feat: enhance require! macro to accept typed error values #335

Merged
jwilger-ai-bot merged 3 commits from feat/327-require-typed-errors into main 2026-04-11 10:20:47 -07:00
jwilger-ai-bot commented 2026-04-11 08:07:20 -07:00 (Migrated from github.com)

Summary

  • Change require! macro single-expression arm to use Into<CommandError> instead of ToString + BusinessRuleViolation
  • Add From<String> and From<&str> impls for CommandError so existing string-literal usage works unchanged
  • Enables: require!(state.is_valid(), MyError::InvalidState) with typed error enums

Test plan

  • New test: developer_uses_typed_error_with_require_macro passes
  • New test: developer_typed_error_allows_passing_condition passes
  • Existing require! tests pass unchanged (backward compatible)
  • All 200 workspace tests pass

Closes #327

## Summary - Change `require!` macro single-expression arm to use `Into<CommandError>` instead of `ToString` + `BusinessRuleViolation` - Add `From<String>` and `From<&str>` impls for `CommandError` so existing string-literal usage works unchanged - Enables: `require!(state.is_valid(), MyError::InvalidState)` with typed error enums ## Test plan - [x] New test: `developer_uses_typed_error_with_require_macro` passes - [x] New test: `developer_typed_error_allows_passing_condition` passes - [x] Existing `require!` tests pass unchanged (backward compatible) - [x] All 200 workspace tests pass Closes #327
jwilger (Migrated from github.com) approved these changes 2026-04-11 10:20:44 -07:00
Sign in to join this conversation.
No description provided.