Skip to content

Commit

Permalink
#184 ensure the approriate amount of errors is returned.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmallen committed Feb 11, 2020
1 parent 846ecc3 commit 66b6b11
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/active_interactor/context/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def failure_errors

private

def clear_all_errors
errors.clear
failure_errors.clear
end

def handle_errors(errors)
if errors.is_a?(String)
failure_errors.add(:context, errors)
Expand All @@ -33,7 +38,9 @@ def merge_errors!(other)
end

def resolve_errors
errors.merge!(failure_errors)
all_errors = (failure_errors.uniq + errors.uniq).compact.uniq
clear_all_errors
all_errors.each { |error| errors.add(error[0], error[1]) }
end
end
end
Expand Down

0 comments on commit 66b6b11

Please sign in to comment.