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)