From 980f5db02851832412008fb3a662c8e3eb53fa72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zapletal?= Date: Thu, 11 Aug 2016 21:39:18 +0200 Subject: [PATCH] Recover from exception while inspecting error response (#48) --- lib/apipie_bindings/api.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/apipie_bindings/api.rb b/lib/apipie_bindings/api.rb index c8dc57b..e8fa7b3 100644 --- a/lib/apipie_bindings/api.rb +++ b/lib/apipie_bindings/api.rb @@ -223,8 +223,8 @@ def http_call(http_method, path, params={}, headers={}, options={}) update_cache(response.headers[:apipie_checksum]) rescue => e clear_credentials if e.is_a? RestClient::Unauthorized - log.debug e.message + "\n" + - inspect_data(e.respond_to?(:response) ? process_data(e.response) : e) + log.error e.message + log.debug inspect_data(e) raise end end @@ -385,7 +385,10 @@ def process_data(response) end def inspect_data(obj) - ApipieBindings::Utils.inspect_data(obj) + ApipieBindings::Utils.inspect_data(obj.respond_to?(:response) ? process_data(obj.response) : obj) + rescue => e + log.debug "Error during inspecting response: #{e.message}" + '' end def create_fake_response(status, body, method, path, args=[])