From 40a438fe8060dd492b3c4683aef51893fd047a42 Mon Sep 17 00:00:00 2001 From: TomRomeo Date: Fri, 15 Mar 2024 13:21:27 +0100 Subject: [PATCH] Add fiber error handling --- backend/services/frontend/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/services/frontend/main.go b/backend/services/frontend/main.go index 566140e4..a483e8e4 100644 --- a/backend/services/frontend/main.go +++ b/backend/services/frontend/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "errors" "fmt" "os" @@ -75,6 +76,11 @@ func main() { fiberConfig := fiber.Config{ ErrorHandler: func(ctx *fiber.Ctx, err error) error { + var e *fiber.Error + if errors.As(err, &e) { + logger.Infof("Fiber error %d with details (%s)!", e.Code, e.Error()) + return ctx.Status(int(e.Code)).SendString(e.Error()) + } parsedError := microErrors.Parse(err.Error()) if parsedError.Code == 0 { parsedError.Code = fiber.StatusInternalServerError