muyu-apiserver/pkg/xerr/errors.go

25 lines
467 B
Go
Raw Normal View History

package xerr
import "fmt"
type BizError struct {
Code int `json:"code"`
Msg string `json:"msg"`
}
func (e *BizError) Error() string {
return fmt.Sprintf("code: %d, msg: %s", e.Code, e.Msg)
}
func New(code int) *BizError {
return &BizError{Code: code, Msg: ErrMsg(code)}
}
func NewMsg(code int, msg string) *BizError {
return &BizError{Code: code, Msg: msg}
}
func NewServerError(msg string) *BizError {
return &BizError{Code: ServerError, Msg: msg}
}