error.go 610 Bytes
Newer Older
kzkzzzz's avatar
kzkzzzz committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
package errm

import (
	"fmt"
	"github.com/go-kratos/kratos/v2/errors"
)

func New(code ErrorCode, message string) *errors.Error {
	return errors.New(int(code), GetCodeText(code), message)
}

func Newf(code ErrorCode, format string, a ...interface{}) *errors.Error {
	return errors.Newf(int(code), GetCodeText(code), fmt.Sprintf(format, a...))
}

func CommonError(message string) *errors.Error {
	return errors.New(int(CommonErrorCode), GetCodeText(CommonErrorCode), message)
}

func ParamsError(message string) *errors.Error {
	return errors.New(int(ParamsErrorCode), GetCodeText(ParamsErrorCode), message)
}