errors

package
v0.0.0-...-b08fcc5 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest         = New499Response(9000, "请求发生错误")
	ErrVerificationFialed = New499Response(9001, "校验失败")
	ErrInternalServer     = New500Response(9002, "服务器内部错误")
	ErrInvalidParam       = New499Response(9003, "请求参数不合法")

	ErrNotLogin     = New499Response(9100, "用户未登录")
	ErrNoPhoneBound = New499Response(9101, "用户未绑定手机号")
	ErrNoPermission = New499Response(9102, "无权限操作")
	ErrActionFailed = New499Response(9103, "操作失败")
	SaveFailed      = New499Response(9104, "保存失败")
)

定义错误

Functions

func Code

func Code(err error) int32

Code returns the status code.

func InternalServerError

func InternalServerError(err error) error

func IsBadRequest

func IsBadRequest(err error) bool

IsBadRequest

func IsInternalServer

func IsInternalServer(err error) bool

IsInternalServer

func IsInvalidParam

func IsInvalidParam(err error) bool

IsInvalidParam

func New499Response

func New499Response(code int, msg string, args ...interface{}) error

func New500Response

func New500Response(code int, msg string, args ...interface{}) error

func NewResponse

func NewResponse(code, statusCode int, msg string, args ...interface{}) error

NewResponse 创建响应错误

func Wrap499Response

func Wrap499Response(err error, msg string, args ...interface{}) error

func Wrap500Response

func Wrap500Response(err error, msg string, args ...interface{}) error

func WrapResponse

func WrapResponse(err error, code, statusCode int, msg string, args ...interface{}) error

Types

type ResponseError

type ResponseError struct {
	Code       int    // 错误码
	Message    string // 错误消息
	StatusCode int    // 响应状态码
	ERR        error  // 响应错误
}

ResponseError 对端错误响应结构

func UnWrapResponse

func UnWrapResponse(err error) *ResponseError

UnWrapResponse 解包响应错误

func (*ResponseError) Error

func (r *ResponseError) Error() string

type StatusError

type StatusError pbErrors.Error

ResponseError 内部服务错误结构

func (*StatusError) Error

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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