22 lines
453 B
Go
22 lines
453 B
Go
package api
|
|
|
|
// ErrCode 错误码,前3位数表示错误类型,后3位数表示具体错误
|
|
type ErrorCode int
|
|
|
|
const (
|
|
CodeInvalidArgument ErrorCode = 10001
|
|
CodeInternalError ErrorCode = 10002
|
|
CodeLinkNotFound ErrorCode = 10003
|
|
)
|
|
|
|
func (e ErrorCode) Message() string {
|
|
switch e {
|
|
case CodeInvalidArgument:
|
|
return "请求参数不正确"
|
|
case CodeLinkNotFound:
|
|
return "链接不存在"
|
|
default:
|
|
return "服务暂时不可用"
|
|
}
|
|
}
|