errorx

package
v1.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2022 License: MulanPSL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Success                     = New(0, "成功", http.StatusOK, gcodes.OK)
	ServerError                 = New(50000, "服务器繁忙", http.StatusInternalServerError, gcodes.Internal)
	ServiceUnavailable          = New(50003, "服务暂不可用", http.StatusServiceUnavailable, gcodes.Unavailable)
	InvalidRequest              = New(40000, "无效请求", http.StatusBadRequest, gcodes.InvalidArgument)
	Unauthenticated             = New(40001, "未登录", http.StatusUnauthorized, gcodes.Unauthenticated)
	UnauthenticatedTokenTimeout = New(40002, "token超时", http.StatusUnauthorized, gcodes.Unauthenticated)
	UnauthenticatedTokenInvalid = New(40003, "无效token", http.StatusUnauthorized, gcodes.Unauthenticated)
	Forbidden                   = New(40004, "无权操作", http.StatusForbidden, gcodes.PermissionDenied)
	NotFound                    = New(40005, "无效数据", http.StatusNotFound, gcodes.NotFound)
	InvalidParams               = New(40006, "请求参数错误", http.StatusBadRequest, gcodes.InvalidArgument)
	DuplicateRequest            = New(40007, "重复请求", http.StatusBadRequest, gcodes.InvalidArgument)
	BusinessError               = New(40008, "业务错误", http.StatusBadRequest, gcodes.InvalidArgument)
	ImportError                 = New(40009, "导入错误", http.StatusBadRequest, gcodes.InvalidArgument)
	UserNotBind                 = New(40010, "未绑定用户", http.StatusBadRequest, gcodes.InvalidArgument)
	ThirdPartyUserMissing       = New(40011, "无法找到之前存在系统的第三方用户", http.StatusBadRequest, gcodes.InvalidArgument)
	MissingActivityID           = New(40012, "无效活动", http.StatusBadRequest, gcodes.InvalidArgument)
	VailSign                    = New(40013, "验签失败", http.StatusBadRequest, gcodes.InvalidArgument)
	DataNotFound                = New(40014, "数据查询失败", http.StatusBadRequest, gcodes.InvalidArgument)
	DataStoreFail               = New(40015, "数据新增失败", http.StatusBadRequest, gcodes.InvalidArgument)
	DataUpdateFail              = New(40016, "数据更新失败", http.StatusBadRequest, gcodes.InvalidArgument)
	DataDestroyFail             = New(40017, "数据删除失败", http.StatusBadRequest, gcodes.InvalidArgument)
	HandleFail                  = New(40018, "操作失败,请稍后重试", http.StatusBadRequest, gcodes.InvalidArgument)
	InvalidToken                = New(40019, "无效token", http.StatusBadRequest, gcodes.InvalidArgument)
	InvalidVerificationCode     = New(40020, "验证码错误", http.StatusBadRequest, gcodes.InvalidArgument)
	PermissionDenied            = New(40021, "权限不足", http.StatusBadRequest, gcodes.InvalidArgument)
	UserNotFound                = New(40022, "用户不存在", http.StatusBadRequest, gcodes.InvalidArgument)
	WrongTimestamp              = New(40023, "时间戳错误", http.StatusBadRequest, gcodes.InvalidArgument)
	WrongSign                   = New(40024, "签名错误", http.StatusBadRequest, gcodes.InvalidArgument)
	DownloadFail                = New(40025, "下载失败", http.StatusBadRequest, gcodes.InvalidArgument)
	Unknown                     = New(40902, "未知错误", http.StatusConflict, gcodes.Unknown)
	AnyError                    = New(-1, "", http.StatusBadRequest, gcodes.Unknown) // be used to set self make err, DO NOT suggest to use this !!!
)

Functions

This section is empty.

Types

type ErrorX

type ErrorX struct {
	// contains filtered or unexported fields
}

func New

func New(code int64, msg string, httpCode int, rpcCode gcodes.Code) *ErrorX

func (*ErrorX) Clone

func (e *ErrorX) Clone() *ErrorX

return a new deep clone errorX

func (*ErrorX) Error

func (e *ErrorX) Error() string

func (*ErrorX) ForceMsg

func (e *ErrorX) ForceMsg(msg string) *ErrorX

DO NOT suggest to use this to change original msg !!!

func (*ErrorX) ForceMsgF

func (e *ErrorX) ForceMsgF(format string, a ...interface{}) *ErrorX

DO NOT suggest to use this to change original msg !!!

func (*ErrorX) ForceNew

func (e *ErrorX) ForceNew(code int64, message string, httpCode int, rpcCode gcodes.Code, details []string) *ErrorX

DO NOT suggest to use this to change original msg !!!

func (*ErrorX) GetCode

func (e *ErrorX) GetCode() int64

func (*ErrorX) GetDetails

func (e *ErrorX) GetDetails() []string

func (*ErrorX) GetHttpCode

func (e *ErrorX) GetHttpCode() int

return this errorX bind http code

func (*ErrorX) GetMsg

func (e *ErrorX) GetMsg() string

func (*ErrorX) GetRpcCode

func (e *ErrorX) GetRpcCode() gcodes.Code

return this errorX bind rpc code

func (*ErrorX) WithDetails

func (e *ErrorX) WithDetails(details ...string) *ErrorX

return a new errorX with details

func (*ErrorX) WithDetailsF

func (e *ErrorX) WithDetailsF(format string, details ...interface{}) *ErrorX

return a new errorX with detailsF

func (*ErrorX) WithHttpCode

func (e *ErrorX) WithHttpCode(httpCode int) *ErrorX

return a new errorX with http code

func (*ErrorX) WithRpcCode

func (e *ErrorX) WithRpcCode(rpcCode gcodes.Code) *ErrorX

return a new errorX with rpc code

type Status

type Status struct {
	*status.Status
}

func FromError

func FromError(err error) *Status

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL