demarches-normaliennes/app/lib/api_entreprise/api/error.rb

23 lines
529 B
Ruby
Raw Normal View History

2020-08-05 18:40:47 +02:00
class APIEntreprise::API::Error < ::StandardError
2020-12-03 16:52:58 +01:00
def initialize(response)
# use uri to avoid sending token
uri = URI.parse(response.effective_url)
msg = <<~TEXT
url: #{uri.host}#{uri.path}
HTTP error code: #{response.code}
body: #{response.body}
2020-12-03 16:52:58 +01:00
curl message: #{response.return_message}
total time: #{response.total_time}
connect time: #{response.connect_time}
response headers: #{response.headers}
TEXT
super(msg)
end
def network_error?
true
end
2020-12-03 16:52:58 +01:00
end