Improved error handling

This commit is contained in:
video-prize-ranch
2022-09-13 16:31:55 -04:00
parent 1263e66f45
commit 5944b7253d
7 changed files with 68 additions and 5 deletions

View File

@@ -25,7 +25,7 @@ func HandleEmbed(c *fiber.Ctx) error {
if err != nil && err.Error() == "ratelimited by imgur" {
return c.Status(429).Render("errors/429", nil)
}
if post.Id == "" || (err != nil && strings.Contains(err.Error(), "404")) {
if err != nil && post.Id == "" && strings.Contains(err.Error(), "404") {
return c.Status(404).Render("errors/404", nil)
}
if err != nil {

View File

@@ -26,10 +26,10 @@ func HandlePost(c *fiber.Ctx) error {
if err != nil && err.Error() == "ratelimited by imgur" {
return c.Status(429).Render("errors/429", nil)
}
if post.Id == "" || (err != nil && strings.Contains(err.Error(), "404")) {
if err != nil && post.Id == "" && strings.Contains(err.Error(), "404") {
return c.Status(404).Render("errors/404", nil)
}
if err != nil {
if err != nil {
return err
}