Documentation ¶
Index ¶
- Constants
- Variables
- type Error
- func (err Error) Equal(e error) bool
- func (err Error) Error() string
- func (err Error) Sprintf(v ...interface{}) Error
- func (err Error) Wrap(core error) error
- func (err Error) WrapPrint(core error, message string) error
- func (err Error) WrapPrintf(core error, format string, message ...interface{}) error
Constants ¶
View Source
const ( // 通用错误码 PARAM_ERROR = 1 //参数错误 SYSTEM_ERROR = 2 //服务内部错误 USER_NOT_LOGIN = 3 //用户未登录 INVALID_REQUEST = 6 //无效请求 DEFAULT_ERROR = 100 //默认错误,未准出的错误码,会修改为此错误码 CUSTOM_ERROR = 101 //自定义错误,无固定错误文案 )
标准准出错误码定义
Variables ¶
View Source
var ErrMsg = map[int]string{ PARAM_ERROR: "请求参数错误", SYSTEM_ERROR: "服务异常,请稍后重试", USER_NOT_LOGIN: "用户Session已失效,请重新登录", INVALID_REQUEST: "请求无效,请稍后再试", DEFAULT_ERROR: "服务开小差了,请稍后再试", }
标准准出错误码文案定义
View Source
var ErrorCustomError = Error{ Code: CUSTOM_ERROR, Message: "%s", }
自定义错误 使用方式:ErrorCustomError.Sprintf(v)
View Source
var ErrorDefault = Error{ Code: DEFAULT_ERROR, Message: ErrMsg[DEFAULT_ERROR], }
默认错误
View Source
var ErrorInvalidRequest = Error{ Code: INVALID_REQUEST, Message: ErrMsg[INVALID_REQUEST], }
无效请求
View Source
var ErrorParamInvalid = Error{ Code: PARAM_ERROR, Message: ErrMsg[PARAM_ERROR], }
参数错误
View Source
var ErrorSuccess = Error{
Code: 0,
Message: "success",
}
*****以下是通用准出错误码的简便定义*********** 正常
View Source
var ErrorSystemError = Error{ Code: SYSTEM_ERROR, Message: ErrMsg[SYSTEM_ERROR], }
系统异常
View Source
var ErrorUserNotLogin = Error{ Code: USER_NOT_LOGIN, Message: ErrMsg[USER_NOT_LOGIN], }
用户未登录
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.