Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transaction extensions to handle failures correctly #25

Merged
merged 2 commits into from
Oct 27, 2024

Commits on Oct 26, 2024

  1. Fix transaction extensions to handle failures correctly

    The `intercepting_failure` method was not handling the block's output
    correctly when it was a failure. It wasn't throwing `:halt` with the
    failure as the given handlers were raising and therefore the throwing
    part was never reached.
    
    We modify the method to pass the failure to the handler and skip the
    throwing part, while extensions need to work in two phases:
    
    1 - From within the transaction block, they intercept a failure a first time
    and assign it to a `result` variable available from the outer scope.
    After that, they raise to rollback the transaction but return the
    `result` variable after that.
    
    2 - From outside the transaction block, they throw again the failure
    when the `result` is actually a failure.
    
    We also make public the `throw_failure` method so that other extensions
    can create similar behavior.
    
    We also add a warning in the ActiveRecord extension to make it clear
    that the `:requires_new` option is not yet supported for this approach.
    We should find a way to make it work in the future.
    
    Closes #23
    waiting-for-dev committed Oct 26, 2024
    Configuration menu
    Copy the full SHA
    9919891 View commit details
    Browse the repository at this point in the history

Commits on Oct 27, 2024

  1. Configuration menu
    Copy the full SHA
    2ca6b0b View commit details
    Browse the repository at this point in the history