lib/retriable.rb in retriable-2.1.0 vs lib/retriable.rb in retriable-3.0.0

- old
+ new

@@ -53,17 +53,14 @@ else return yield(try) end rescue *[*exception_list] => exception if on.kind_of?(Hash) - patterns = [*on[exception.class]] - message_match = patterns.empty? ? true : false - patterns.each do |pattern| - if !!(exception.message =~ pattern) - message_match = true - break - end + message_match = exception_list.select { |e| exception.is_a?(e) }.inject(false) do |match, e| + break match if match + match || [*on[e]].empty? || [*on[e]].any? { |pattern| exception.message =~ pattern } end + raise unless message_match end interval = intervals[index] on_retry.call(exception, try, elapsed_time.call, interval) if on_retry