Documentation ¶
Index ¶
- Constants
- Variables
- type TrError
- func Aborted(reason string, args ...interface{}) *TrError
- func AlreadyExists(reason string, args ...interface{}) *TrError
- func Canceled(reason string, args ...interface{}) *TrError
- func ConfigurationError(reason string, args ...interface{}) *TrError
- func CustomAbortedError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomAlreadyExistsError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomCanceledError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomConfigurationError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomDBError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomDeadlineExceededError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomError(code uint32, internalCode uint32, message, reason string, args ...interface{}) *TrError
- func CustomInternalError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomInvalidArgumentError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomNotFoundError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomPermissionDeniedError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomResourceExhaustedError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomUnauthenticatedError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomUnavailableError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomUnimplementedError(code uint32, msg, reason string, args ...interface{}) *TrError
- func CustomUnknownError(code uint32, msg, reason string, args ...interface{}) *TrError
- func DBError(reason string, args ...interface{}) *TrError
- func DeadlineExceeded(reason string, args ...interface{}) *TrError
- func DefaultTrError(msg string) *TrError
- func Internal(reason string, args ...interface{}) *TrError
- func InvalidArgument(reason string, args ...interface{}) *TrError
- func New(code uint32, message string) *TrError
- func NewErrorWithF(code uint32, internalCode uint32, message, reason string, args ...interface{}) *TrError
- func NewF(code uint32, message, reason string, args ...interface{}) *TrError
- func NewTrError(code int32, msg string) *TrError
- func NotFound(reason string, args ...interface{}) *TrError
- func PermissionDenied(reason string, args ...interface{}) *TrError
- func ResourceExhausted(reason string, args ...interface{}) *TrError
- func Unauthenticated(reason string, args ...interface{}) *TrError
- func Unavailable(reason string, args ...interface{}) *TrError
- func Unimplemented(reason string, args ...interface{}) *TrError
- func Unknown(reason string, args ...interface{}) *TrError
Constants ¶
const ( SUCCESS = 200 //成功 ERROR = 500 //失败 InvalidParams = 400 //参数错误 )
Variables ¶
var ( TR_SUCCESS = &TrError{200, "成功"} TR_BAD_REQUEST = &TrError{400, "无效的请求"} TR_ERROR = &TrError{500, "服务器错误"} TR_SYSTEM_ERROR = &TrError{5001, "系统错误"} TR_SYSTEM_BUSY = &TrError{5002, "系统繁忙"} TR_TIMEOUT = &TrError{5003, "请求超时"} TR_INVALID_TOKEN = &TrError{4001, "无效token"} TR_FILE_TOO_LARGE = &TrError{4002, "文件过大"} TR_DUPLICATE_PRIMARY_KEY = &TrError{4003, "重复主键"} TR_LOGIN_ERROR = &TrError{4004, "登录错误"} TR_NOT_LOGIN = &TrError{4005, "用户未登录"} TR_USER_NOT_EXIST = &TrError{4006, "用户不存在"} TR_DISABLED_USER = &TrError{4007, "用户已被禁用"} TR_WRONG_PASSWORD = &TrError{4008, "密码错误"} TR_NO_PERMISSION = &TrError{4019, "无权限"} TR_ILLEGAL_OPERATION = &TrError{4010, "非法操作"} TR_RECORD_NOT_FOUND = &TrError{4011, "记录不存在"} TR_EMAIL_REGISTERED = &TrError{4012, "邮箱已被注册"} TR_LOGIN_UNSUPPORT = &TrError{4013, "暂不支持此方式登录"} // ugc校验错误 ContentIllegal = &TrError{10201, "文字包含违规信息"} ImageIllegal = &TrError{10202, "图片包含违规信息"} VideoIllegal = &TrError{10203, "视频包含违规信息"} // 数据库错误 DBNotFoundError = &TrError{Code: 80001, Message: "data not found"} TR_ACCESS_TOO_FREQUENTLY = &TrError{99999, "访问太频繁"} )
Functions ¶
This section is empty.
Types ¶
type TrError ¶
func AlreadyExists ¶
AlreadyExists returns resource already exists Error
func ConfigurationError ¶
ConfigurationError returns configuration Error
func CustomAbortedError ¶
CustomAbortedError return abort Error
func CustomAlreadyExistsError ¶
CustomAlreadyExistsError returns resource already exists Error
func CustomCanceledError ¶
CustomCanceledError returns Error for canceled
func CustomConfigurationError ¶
CustomConfigurationError returns configuration Error
func CustomDBError ¶
CustomDBError returns database Error
func CustomDeadlineExceededError ¶
CustomDeadlineExceededError returns deadline exceeded Error
func CustomError ¶
func CustomError(code uint32, internalCode uint32, message, reason string, args ...interface{}) *TrError
CustomError returns custom Error
func CustomInternalError ¶
CustomInternalError return inner server Error
func CustomInvalidArgumentError ¶
CustomInvalidArgumentError returns invalid argument Error
func CustomNotFoundError ¶
CustomNotFoundError returns resource not found Error
func CustomPermissionDeniedError ¶
CustomPermissionDeniedError returns permission denied Error
func CustomResourceExhaustedError ¶
CustomResourceExhaustedError returns resource exhaust Error
func CustomUnauthenticatedError ¶
CustomUnauthenticatedError returns unauthenticated Error
func CustomUnavailableError ¶
CustomUnavailableError return service unavailable Error
func CustomUnimplementedError ¶
CustomUnimplementedError return unimplemented Error
func CustomUnknownError ¶
CustomUnknownError returns unknown Error
func DeadlineExceeded ¶
DeadlineExceeded returns deadline exceeded Error
func DefaultTrError ¶
func InvalidArgument ¶
InvalidArgument returns invalid argument Error
func New ¶
New Error with message and reason func New(code uint32, message, reason string, internalCode uint32) *TrError {
func NewErrorWithF ¶
func NewErrorWithF(code uint32, internalCode uint32, message, reason string, args ...interface{}) *TrError
NewErrorWithF Error with reason fmt
func NewTrError ¶
func PermissionDenied ¶
PermissionDenied returns permission denied Error
func ResourceExhausted ¶
ResourceExhausted returns resource exhaust Error
func Unauthenticated ¶
Unauthenticated returns unauthenticated Error
func Unavailable ¶
Unavailable return service unavailable Error
func Unimplemented ¶
Unimplemented return unimplemented Error
func (*TrError) GRPCStatus ¶
GRPCStatus 需要继承该方法,才能正常返回应用定义的错误码
func (*TrError) GetCodeInt32 ¶
GetCodeInt32 建议使用,获取int32类型的错误码