Skip to content

Commit

Permalink
chore: add better logging error on logs
Browse files Browse the repository at this point in the history
  • Loading branch information
robcxyz committed Mar 26, 2024
1 parent 21b3ba1 commit 63b75dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/api/rest/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package rest

import (
"encoding/json"
"gorm.io/gorm"
"strconv"

fiber "github.com/gofiber/fiber/v2"
Expand Down Expand Up @@ -90,10 +91,13 @@ func handlerGetLogs(c *fiber.Ctx) error {
params.Method,
)
if err != nil {
if err == gorm.ErrRecordNotFound {
c.Status(404)
return c.SendString(`{"error": "logs not found"}`)
}
c.Status(500)
zap.S().Warn(
"Endpoint=handlerGetLogs",
" Error=Could not retrieve logs: ", err.Error(),
"Endpoint=handlerGetLogs", " Error=Could not retrieve logs: ", err.Error(),
)
return c.SendString(`{"error": "could not retrieve logs"}`)
}
Expand Down

0 comments on commit 63b75dd

Please sign in to comment.