demarches-normaliennes/app/lib/api_entreprise/api/error.rb
2024-04-09 14:25:17 +02:00

22 lines
529 B
Ruby

class APIEntreprise::API::Error < ::StandardError
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}
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
end