mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
initial commit
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user