package utils import ( "errors" "gitlab.com/mbugroup/lti-api.git/internal/common/validation" "gitlab.com/mbugroup/lti-api.git/internal/response" "github.com/gofiber/fiber/v2" ) func ErrorHandler(c *fiber.Ctx, err error) error { if message, errorsMap := validation.CustomErrorMessages(err); len(errorsMap) > 0 { return response.Error(c, fiber.StatusBadRequest, message, nil) } 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) } func BadRequest(msg string) error { return fiber.NewError(fiber.StatusBadRequest, msg) } func NotFound(msg string) error { return fiber.NewError(fiber.StatusNotFound, msg) } func Internal(msg string) error { return fiber.NewError(fiber.StatusInternalServerError, msg) }