icechen 372d70969b
All checks were successful
continuous-integration/drone/push Build is passing
feat: 参数校验,错误处理demo
2022-01-13 02:23:00 +08:00

28 lines
552 B
Go

package user
import "github.com/gofiber/fiber/v2"
var ErrorUser = fiber.NewError(0, "错误")
func NewError(msg string) error {
return fiber.NewError(fiber.StatusInternalServerError, msg)
}
func NewErrorWithCode(code int, msg string) error {
return fiber.NewError(code, msg)
}
func WarpError(err error) error {
if err == nil {
return nil
}
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
func WarpErrorWithCode(code int, err error) error {
if err == nil {
return nil
}
return fiber.NewError(code, err.Error())
}