YoutubeAPI: add logging on API error

This commit is contained in:
Samantaz Fox 2021-07-28 15:37:15 +02:00
parent 68d69df6d3
commit 56ba453d95
No known key found for this signature in database
GPG Key ID: F42821059186176E

View File

@ -410,6 +410,11 @@ module YoutubeAPI
code = initial_data["error"]["code"] code = initial_data["error"]["code"]
message = initial_data["error"]["message"].to_s.sub(/(\\n)+\^$/, "") message = initial_data["error"]["message"].to_s.sub(/(\\n)+\^$/, "")
# Logging
LOGGER.error("YoutubeAPI: Got error #{code} when requesting #{endpoint}")
LOGGER.error("YoutubeAPI: #{message}")
LOGGER.info("YoutubeAPI: POST data was: #{data.to_s}")
raise InfoException.new("Could not extract JSON. Youtube API returned \ raise InfoException.new("Could not extract JSON. Youtube API returned \
error #{code} with message:<br>\"#{message}\"") error #{code} with message:<br>\"#{message}\"")
end end