Skip to content

Commit d534c03

Browse files
authored
Raise error for 429 and other 4xx codes
The API can return a response.body that looks like: ``` "{\"error\": \"Limit of webhooks created exceeded. Please check your account limits and upgrade your plan.\"}" ``` With HTTP code `429`. The current code silently ignores errors like this.
1 parent 18fb5b5 commit d534c03

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/blockcypher/api.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,12 @@ def api_http_call(http_method, api_path, query, json_payload: nil)
371371
end
372372

373373
response = http.request(request)
374+
response_code = response.code.to_i
374375

375376
# Detect errors/return 204 empty body
376-
if response.code == '400'
377+
if response_code >= 400
377378
raise Error.new(uri.to_s + ' Response:' + response.body)
378-
elsif response.code == '204'
379+
elsif response_code == 204
379380
return nil
380381
end
381382

0 commit comments

Comments
 (0)