module Gateway::Feature::ErrorHandle

Protected Instance Methods

bad_gateway_errors(action) click to toggle source
# File lib/gateway/feature/error_handle.rb, line 22
def bad_gateway_errors(action)
  raise "Abstract Method"
end
run_bad_gateway_callbacks(action) click to toggle source
# File lib/gateway/feature/error_handle.rb, line 30
def run_bad_gateway_callbacks(action)
  raise "Abstract Method"
end
run_timeout_callbacks(action) click to toggle source
# File lib/gateway/feature/error_handle.rb, line 34
def run_timeout_callbacks(action)
  raise "Abstract Method"
end
timeout_errors(action) click to toggle source
# File lib/gateway/feature/error_handle.rb, line 26
def timeout_errors(action)
  raise "Abstract Method"
end
with_error_handle(action, conn, opts={}, &block) click to toggle source
# File lib/gateway/feature/error_handle.rb, line 6
def with_error_handle(action, conn, opts={}, &block)
  return block.call if opts[:handle_error] == false

  begin
    block.call
  rescue *bad_gateway_errors(action) => e
    run_bad_gateway_callbacks(action)
    reconnect(conn)
    raise Gateway::BadGateway.wrap(e)
  rescue *timeout_errors(action) => e
    run_timeout_callbacks(action)
    reconnect(conn)
    raise Gateway::GatewayTimeout.wrap(e)
  end
end