Enhance require! macro to accept typed error values #327
Labels
No labels
adr
automated
bug
chore
dependencies
documentation
enhancement
epic
github-actions
P1-high
P2-medium
P3-low
release
research
rust
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jwilger/eventcore#327
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
When using
CommandLogic::handle()with typed business-rule error enums (viathiserror::Error+From<E> for CommandError), therequire!macro can't be used because it only accepts string literals.This forces verbose if/return patterns instead of concise
require!syntax:Proposal
Enhance
require!to accept any value that implementsInto<CommandError>:The macro should detect whether the second argument is a string literal or an expression and:
CommandError::BusinessRuleViolation(s)).into()to convert via theFromimplIdeally,
CommandErrorshould also preserve a reference to the original typed error for downstream consumers that need to match on specific variants.Origin
Identified during slipstream-consulting/stochastic_macro PR #99 review.
Completed in #335 — require! macro now accepts Into typed error values.