Commit 6263e870 authored by sergio1990's avatar sergio1990

Trying to fix problem with null result

parent cf0a2629
......@@ -11,7 +11,7 @@ module BetfairApiNgRails
base.send :class_eval, <<-CODE
def request_with_error_handling(method, params = {})
res = request_without_error_handling(method, params)
raise_exception(res.error_info) if res.has_error?
raise_exception(res.try(:error_info) || default_error_info) if res.nil? || res.has_error?
res
end
alias_method :request_without_error_handling, :request
......@@ -25,6 +25,10 @@ module BetfairApiNgRails
raise BetfairApiNgRails::APINGException.new(error), "Error in #{error[:type]} section"
end
def default_error_info
{type: :SESSION, info: { 'code' => -32099 }}
end
end
end
end
......
......@@ -10,7 +10,9 @@ module BetfairApiNgRails
base.send :class_eval, <<-CODE
def request_with_logging(method, params = {})
write_income_request method, params
request_without_logging(method, params).tap { |res| write_result(res) }
res = request_without_logging(method, params)
write_result(res)
res
end
alias_method :request_without_logging, :request
alias_method :request, :request_with_logging
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment