123456789101112131415161718192021 |
- package ierr
- import "fmt"
- type IError struct {
- Code Code `json:"code"`
- Msg string `json:"msg"` //跟code一致的
- MoreInfo string `json:"more_info"`
- }
- func NewIError(code Code, moreInfo string) *IError {
- return &IError{Code: code, MoreInfo: moreInfo}
- }
- func NewIErrorf(code Code, format string, args ...interface{}) *IError {
- return &IError{Code: code, MoreInfo: fmt.Sprintf(format, args...)}
- }
- func (e *IError) Error() string {
- return fmt.Sprintf("code(%d),err(%s)", e.Code, e.MoreInfo)
- }
|