Documentation ¶
Index ¶
- Constants
- Variables
- func GetErrCodeMsg(err error) (errCode uint32, errMsg string)
- func GetStack() string
- func Init(errs map[uint32]string)
- func IsCodeErr(errcode uint32) bool
- func IsDatabaseNoRowsError(err error) bool
- func IsErrCode(err error, code uint32) bool
- func MapErrMsg(errcode uint32) string
- func NewError(errCode uint32) error
- func NewErrorMsg(errCode uint32, errMsg string) error
- type CodeError
- type CodeErrorBuilder
- func (b *CodeErrorBuilder) Build() *CodeError
- func (b *CodeErrorBuilder) WithErrCode(errCode uint32) *CodeErrorBuilder
- func (b *CodeErrorBuilder) WithErrMsg(errMsg string) *CodeErrorBuilder
- func (b *CodeErrorBuilder) WithHost(host string) *CodeErrorBuilder
- func (b *CodeErrorBuilder) WithShowType(showType uint32) *CodeErrorBuilder
- func (b *CodeErrorBuilder) WithTraceId(traceId string) *CodeErrorBuilder
Constants ¶
View Source
const CAPTCHA_ERROR uint32 = 700
View Source
const DB_ERROR uint32 = 555
View Source
const ETCD_ERROR uint32 = 777
View Source
const FORBIDDEN_ERROR uint32 = 403
View Source
const NOT_FOUND_ERROR uint32 = 404
View Source
const OK uint32 = 0
常用错误码 成功返回
View Source
const REDIS_ERROR uint32 = 666
View Source
const REQUEST_PARAM_ERROR uint32 = 400
全局错误码 client
View Source
const SERVER_COMMON_ERROR uint32 = 500
server
View Source
const ShowTypeMessageError uint32 = 2
View Source
const ShowTypeMessageWarn uint32 = 1
View Source
const ShowTypeNotification uint32 = 4
View Source
const ShowTypePage uint32 = 9
View Source
const ShowTypeSilent uint32 = 0
错误处理枚举 showType?: number; // error display type: 0 silent; 1 message.warn; 2 message.error; 4 notification; 9 page
View Source
const TOKEN_EXPIRE_ERROR uint32 = 401
View Source
const USER_EXISTS_ERROR uint32 = 704
View Source
const USER_LOGIN_ERROR uint32 = 703
View Source
const USER_NOT_EXISTS_ERROR uint32 = 701
Variables ¶
View Source
var ( ErrNotFound = NewErrCodeMsg(NOT_FOUND_ERROR, "not found") ErrUserNoExists = NewErrCodeMsg(USER_NOT_EXISTS_ERROR, "user not found") ErrUserExists = NewErrCodeMsg(USER_EXISTS_ERROR, "user exists") ErrUserForbidden = NewErrCode(FORBIDDEN_ERROR) ErrUserLogin = NewErrCode(USER_LOGIN_ERROR) ErrCaptcha = NewErrCodeMsg(CAPTCHA_ERROR, "captcha error") ErrRequestParamError = NewErrCode(REQUEST_PARAM_ERROR) ErrDBError = NewErrCode(DB_ERROR) ErrServerError = NewErrCode(SERVER_COMMON_ERROR) ErrRedisError = NewErrCode(REDIS_ERROR) ErrEtcdError = NewErrCode(ETCD_ERROR) )
Functions ¶
func IsDatabaseNoRowsError ¶ added in v1.2.148
func NewErrorMsg ¶ added in v1.2.98
Types ¶
type CodeError ¶
type CodeError struct {
// contains filtered or unexported fields
}
func NewErrCode ¶
func NewErrCodeMsg ¶
func NewParamErrMsg ¶
func (*CodeError) GetShowType ¶ added in v1.2.177
func (*CodeError) GetTraceId ¶ added in v1.2.177
type CodeErrorBuilder ¶ added in v1.2.177
type CodeErrorBuilder struct {
// contains filtered or unexported fields
}
CodeErrorBuilder 是 CodeError 的构建器
func GetCodeError ¶ added in v1.2.177
func GetCodeError(err error) *CodeErrorBuilder
CodeErrorBuilder.build() 构建 CodeError
返回错误码 CodeErrorBuilder
func NewCodeErrorBuilder ¶ added in v1.2.177
func NewCodeErrorBuilder() *CodeErrorBuilder
NewCodeErrorBuilder 创建一个新的 CodeErrorBuilder
func (*CodeErrorBuilder) Build ¶ added in v1.2.177
func (b *CodeErrorBuilder) Build() *CodeError
Build 构建并返回 CodeError 实例
func (*CodeErrorBuilder) WithErrCode ¶ added in v1.2.177
func (b *CodeErrorBuilder) WithErrCode(errCode uint32) *CodeErrorBuilder
WithErrCode 设置错误码
func (*CodeErrorBuilder) WithErrMsg ¶ added in v1.2.177
func (b *CodeErrorBuilder) WithErrMsg(errMsg string) *CodeErrorBuilder
WithErrMsg 设置错误信息
func (*CodeErrorBuilder) WithHost ¶ added in v1.2.177
func (b *CodeErrorBuilder) WithHost(host string) *CodeErrorBuilder
WithHost 设置主机信息
func (*CodeErrorBuilder) WithShowType ¶ added in v1.2.177
func (b *CodeErrorBuilder) WithShowType(showType uint32) *CodeErrorBuilder
WithShowType 设置显示类型
func (*CodeErrorBuilder) WithTraceId ¶ added in v1.2.177
func (b *CodeErrorBuilder) WithTraceId(traceId string) *CodeErrorBuilder
WithTraceId 设置追踪ID
Click to show internal directories.
Click to hide internal directories.