From 3ce622772c37a3bd5d2ca5751bc0036021a728fe Mon Sep 17 00:00:00 2001 From: Tomas Strachota Date: Wed, 22 Mar 2017 12:25:20 +0100 Subject: [PATCH] Fixes #56 - do not hide exceptions during cache retrieval (#57) --- lib/apipie_bindings/api.rb | 6 +++--- lib/apipie_bindings/exceptions.rb | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/apipie_bindings/api.rb b/lib/apipie_bindings/api.rb index e7882a1..6f37f8e 100644 --- a/lib/apipie_bindings/api.rb +++ b/lib/apipie_bindings/api.rb @@ -277,11 +277,11 @@ def retrieve_apidoc unless response begin response = retrieve_apidoc_call("/apidoc/v#{@api_version}.json") - rescue + rescue Exception => e raise ApipieBindings::DocLoadingError.new( - "Could not load data from #{@uri}\n"\ + "Could not load data from #{@uri}: #{e.message}\n"\ " - is your server down?\n"\ - " - was rake apipie:cache run when using apipie cache? (typical production settings)") + " - was rake apipie:cache run when using apipie cache? (typical production settings)", e) end end File.open(apidoc_cache_file, "w") { |f| f.write(response.body) } diff --git a/lib/apipie_bindings/exceptions.rb b/lib/apipie_bindings/exceptions.rb index 0b0b90a..382cdd7 100644 --- a/lib/apipie_bindings/exceptions.rb +++ b/lib/apipie_bindings/exceptions.rb @@ -1,7 +1,13 @@ module ApipieBindings class ConfigurationError < StandardError; end - class DocLoadingError < StandardError; end + class DocLoadingError < StandardError + attr_reader :original_error + def initialize(msg, original_error) + super(msg) + @original_error = original_error + end + end class AuthenticatorMissingError < StandardError; end ErrorData = Struct.new(:kind, :argument, :details)