Skip to content

Commit

Permalink
Add error handling around empty imgur response data
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjzabel committed Feb 7, 2025
1 parent 0af3dfe commit c22b790
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/handlers/telegram/imgur.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func getImgurLink(tg *Client, tgLink string) string {
tg.logger.LogError("Could not retrieve imgur json data:", err)
}

if resp.Data == nil {
tg.logger.LogError("Imgur response data was null. Possible API rate limiting.")
return ""
}

if resp.Data.Deletehash != "" {
deleteLink := "https://imgur.com/delete/" + resp.Data.Deletehash
tg.logger.LogInfo("Deletion link for", resp.Data.Link, "is", deleteLink)
Expand Down

0 comments on commit c22b790

Please sign in to comment.