Fix lint errors: add error checks for errcheck linter
All checks were successful
Run Tests / Run Go Tests (push) Successful in 2m24s
Run Tests / Lint Code (push) Successful in 3m36s

- Add error check for JSON response in panic handler
- Remove duplicate defer CloseDB() call (handled in shutdown)
- Add error checks for all WriteField() calls in test files
- Add error checks for CreateFormFile() and Write() calls
- Fix golangci-lint Go 1.25 compatibility by installing from source
This commit is contained in:
2025-11-21 15:55:12 +03:00
parent 58df1359e1
commit 1db56d6741
4 changed files with 87 additions and 39 deletions

View File

@@ -43,23 +43,25 @@ func ErrorHandler(c *fiber.Ctx) error {
// RecoverHandler recovers from panics and returns a proper error response
func RecoverHandler() fiber.Handler {
return func(c *fiber.Ctx) error {
defer func() {
if r := recover(); r != nil {
// Log panic with context
log.Printf("Panic recovered: %v | Method: %s | Path: %s | IP: %s",
r,
c.Method(),
c.Path(),
c.IP(),
)
defer func() {
if r := recover(); r != nil {
// Log panic with context
log.Printf("Panic recovered: %v | Method: %s | Path: %s | IP: %s",
r,
c.Method(),
c.Path(),
c.IP(),
)
// Return error response
c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"success": false,
"error": "Internal Server Error",
})
}
}()
// Return error response
if err := c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
"success": false,
"error": "Internal Server Error",
}); err != nil {
log.Printf("Failed to send error response: %v", err)
}
}
}()
return c.Next()
}