module Flow::Operation::ErrorHandler

Public Instance Methods

handle_error(error_class, problem: error_class.name.demodulize.underscore, with: nil, &block) click to toggle source
# File lib/flow/operation/error_handler.rb, line 12
def handle_error(error_class, problem: error_class.name.demodulize.underscore, with: nil, &block)
  failure problem

  rescue_from(error_class) { |exception| fail!(problem.to_sym, exception: exception) }

  if with.present?
    rescue_from(error_class, with: with)
  elsif block_given?
    rescue_from(error_class, &block)
  end
end
handle_errors(*errors) click to toggle source
# File lib/flow/operation/error_handler.rb, line 24
def handle_errors(*errors)
  errors.flatten.each(&method(:handle_error))
end