package utils import ( "fmt" ) type ErrorWithCode struct { str string code string intCode int } func NewErrorCode(err, code string) *ErrorWithCode { return &ErrorWithCode{ str: err, code: code, intCode: Str2Int(code), } } func NewErrorIntCode(err string, code int) *ErrorWithCode { return &ErrorWithCode{ str: err, code: Int2Str(code), intCode: code, } } func (e *ErrorWithCode) Error() string { return fmt.Sprintf("%s, code:%s", e.str, e.code) } func (e *ErrorWithCode) Code() string { return e.code } func (e *ErrorWithCode) IntCode() int { return e.intCode }