retry exponentially on api entreprise timeout
This commit is contained in:
parent
78a40b5176
commit
f56235c7ee
4 changed files with 17 additions and 2 deletions
|
@ -27,6 +27,9 @@ class ApiEntreprise::API
|
|||
class ServiceUnavailable < StandardError
|
||||
end
|
||||
|
||||
class TimedOut < StandardError
|
||||
end
|
||||
|
||||
def self.entreprise(siren, procedure_id)
|
||||
call_with_siret(ENTREPRISE_RESOURCE_NAME, siren, procedure_id)
|
||||
end
|
||||
|
@ -104,6 +107,8 @@ class ApiEntreprise::API
|
|||
raise BadGateway, "url: #{url}"
|
||||
elsif response.code == 503
|
||||
raise ServiceUnavailable, "url: #{url}"
|
||||
elsif response.timed_out?
|
||||
raise TimedOut, "url: #{url}"
|
||||
else
|
||||
raise RequestFailed,
|
||||
<<~TEXT
|
||||
|
@ -111,7 +116,6 @@ class ApiEntreprise::API
|
|||
headers: #{response.headers}
|
||||
body: #{response.body}
|
||||
curl message: #{response.return_message}
|
||||
timeout: #{response.timed_out?}
|
||||
TEXT
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue