errors

package
v8.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	New          = errors.New
	Wrap         = errors.Wrap
	Wrapf        = errors.Wrapf
	WithStack    = errors.WithStack
	WithMessage  = errors.WithMessage
	WithMessagef = errors.WithMessagef
)

Define alias

View Source
var (
	ErrInvalidToken    = NewResponse(9999, 401, "invalid signature")
	ErrNoPerm          = NewResponse(0, 401, "no permission")
	ErrNotFound        = NewResponse(0, 404, "not found")
	ErrMethodNotAllow  = NewResponse(0, 405, "method not allowed")
	ErrTooManyRequests = NewResponse(0, 429, "too many requests")
	ErrInternalServer  = NewResponse(0, 500, "internal server error")
	ErrBadRequest      = New400Response("bad request")
	ErrInvalidParent   = New400Response("not found parent node")
	ErrUserDisable     = New400Response("user forbidden")
)

Functions

func New400Response

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

func New500Response

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

func NewResponse

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

func Wrap400Response

func Wrap400Response(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, status int, msg string, args ...interface{}) error

Types

type ResponseError

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

ResponseError 定义响应错误

func UnWrapResponse

func UnWrapResponse(err error) *ResponseError

func (*ResponseError) Error

func (r *ResponseError) Error() string

Jump to

Keyboard shortcuts

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