Module: Axn::Internal::ContractErrorHandling
- Defined in:
- lib/axn/internal/contract_error_handling.rb
Class Method Summary collapse
-
.with_contract_error_handling(exception_class:, message:, field_identifier:) { ... } ⇒ Object
Executes a block, allowing fail! and done! to propagate normally, but wrapping other StandardErrors in the specified exception class.
Class Method Details
.with_contract_error_handling(exception_class:, message:, field_identifier:) { ... } ⇒ Object
Executes a block, allowing fail! and done! to propagate normally, but wrapping other StandardErrors in the specified exception class.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/axn/internal/contract_error_handling.rb', line 18 def with_contract_error_handling(exception_class:, message:, field_identifier:) yield rescue Axn::Failure, Axn::Internal::EarlyCompletion => e raise e # Re-raise control flow exceptions without wrapping rescue StandardError => e = if .is_a?(Proc) .call(field_identifier, e) else format(, field_identifier, e.) end raise exception_class, , cause: e end |