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

the after execute callback is not aware of the failure when compose failed #457

Closed
Pierre-Michard opened this issue Mar 13, 2019 · 0 comments
Assignees
Labels

Comments

@Pierre-Michard
Copy link

Pierre-Michard commented Mar 13, 2019

class DummyInteraction < ActiveInteraction::Base
    integer :integer_param

    validates :integer_param, numericality: { geater_than: 0 }

    def execute
      unless integer_param > 10
        errors.add(:integer_param, :invalid)
      end
    end
  end

  class DummyWithcompose < ActiveInteraction::Base
    integer :integer_param
   
      set_callback :execute,
                 :after,
                 :log_errors,
                 if: -> { errors.any? }
  
    private:

    def execute
      compose(DummyInteraction, integer_param: integer_param)
    end

    def log_errors
      error_msg = errors.full_messages.to_sentence
      Rails.logger.info(
        "Interaction #{self.class.name} failed: '#{error_msg}'"
      )
    end
  end

The following command fails but does not log the issue:

  DummyWithcompose.run(integer_param: 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants