package common import ( "errors" "fmt" "github.com/gofiber/fiber/v2" ) func ErrorHandler(ctx *fiber.Ctx, err error) error { // Status code defaults to 500 code := fiber.StatusInternalServerError // Retrieve the custom status code if it's a *fiber.Error var e *fiber.Error if errors.As(err, &e) { code = e.Code } return RespError(ctx, code, fmt.Sprintf("Error: %s", err.Error())) }