Skip to content

Commit

Permalink
Merge pull request #6 from jchristgit/improve-logging-for-non-200s
Browse files Browse the repository at this point in the history
Improve logging for non-200 response codes on getting policy file
  • Loading branch information
jb3 authored Aug 1, 2024
2 parents fcb343a + 66cbbb9 commit b8b80d8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/ff_bot/policy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@ defmodule FFBot.Policy do
"""
def get_policy_file(token, owner, repo) do
# Get the file
file =
response =
GitHub.Request.request(
:get,
GitHub.Endpoint.policy_file(owner, repo),
auth: {:token, token}
)

# If we found the file, parse it, else return a missing file error.
case file do
{200, file} -> parse_file(file["content"])
_ -> {:error, :missing_config}
case response do
{200, json} ->
parse_file(json["content"])

{status, json} ->
Logger.error("Retrieved code #{status} with response #{inspect(json)} for policy file at #{owner}/#{repo}")
{:error, :missing_config}
end
end

Expand Down

0 comments on commit b8b80d8

Please sign in to comment.