Skip to content

Commit

Permalink
on failed gh request add ratelimit headers to error message
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettrowell committed Apr 30, 2024
1 parent f8114e5 commit bcbd7c3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/onceover/vendored_modules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ def github_get(url, params)
request['Accept'] = 'application/vnd.github+json'
request['X-GitHub-Api-Version'] = '2022-11-28'
response = http.request(request)

case response
when Net::HTTPOK # 200
MultiJson.load(response.body)
else
raise "#{response.code} #{response.message}"
# Expose the ratelimit response headers
# https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#checking-the-status-of-your-rate-limit
ratelimit_headers = response.to_hash.select { |k, v| k =~ /x-ratelimit.*/ }
raise "#{response.code} #{response.message} #{ratelimit_headers}"
end
end

Expand Down

0 comments on commit bcbd7c3

Please sign in to comment.