initial commit

This commit is contained in:
Hafizh A. Y
2025-09-25 10:46:46 +07:00
parent c43544e5e8
commit 10506238ae
64 changed files with 3564 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package utils
import (
"errors"
"github.com/hafizhproject45/Golang-Boilerplate.git/internal/response"
"github.com/hafizhproject45/Golang-Boilerplate.git/internal/validation"
"github.com/gofiber/fiber/v2"
)
func ErrorHandler(c *fiber.Ctx, err error) error {
if errorsMap := validation.CustomErrorMessages(err); len(errorsMap) > 0 {
return response.Error(c, fiber.StatusBadRequest, "Bad Request", errorsMap)
}
var fiberErr *fiber.Error
if errors.As(err, &fiberErr) {
return response.Error(c, fiberErr.Code, fiberErr.Message, nil)
}
return response.Error(c, fiber.StatusInternalServerError, "Internal Server Error", nil)
}
func NotFoundHandler(c *fiber.Ctx) error {
return response.Error(c, fiber.StatusNotFound, "Endpoint Not Found", nil)
}