errors

package
v0.0.0-...-1142a2b Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	New               = errors.New
	Wrap              = errors.Wrap
	Wrapf             = errors.Wrapf
	ErrNormal         = New("返回code为200,特殊异常")
	ErrForbidden      = New("禁止访问")
	ErrNotFound       = New("资源不存在")
	ErrBadRequest     = New("请求无效")
	ErrUnauthorized   = New("未授权")
	ErrInternalServer = New("服务器错误")
	ErrImplemented    = New("API未实现触发异常")
)

定义通用错误

Functions

func NewBadRequestError

func NewBadRequestError(code string, msg ...string) error

NewBadRequestError 创建请求无效错误

func NewForbiddenError

func NewForbiddenError(code string, msg ...string) error

NewForbiddenError 创建资源禁止访问错误

func NewInternalServerError

func NewInternalServerError(code string, msg ...string) error

NewInternalServerError 创建服务器错误

func NewMessageError

func NewMessageError(parent error, code string, msg ...string) error

NewMessageError 创建自定义消息错误

func NewNormalError

func NewNormalError(code string, msg ...string) error

func NewNotFoundError

func NewNotFoundError(code string, msg ...string) error

NewNotFoundError 创建资源不存在错误

func NewUnauthorizedError

func NewUnauthorizedError(code string, msg ...string) error

NewUnauthorizedError 创建未授权错误

func NewValidatorError

func NewValidatorError(err error) error

NewValidatorError NewValidatorError

func NewValidatorErrorStr

func NewValidatorErrorStr(err error) string

NewValidatorErrorStr NewValidatorErrorStr

func ValidationErrorToText

func ValidationErrorToText(e validator.FieldError) string

ValidationErrorToText

Types

type CommonError

type CommonError struct {
	Errors map[string]interface{} `json:"errors"`
}

CommonError error

func ThrowValidatorError

func ThrowValidatorError(err error) CommonError

ThrowValidatorError ThrowValidatorError

type MessageError

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

MessageError 自定义消息错误

func (*MessageError) Code

func (m *MessageError) Code() string

func (*MessageError) Error

func (m *MessageError) Error() string

func (*MessageError) Parent

func (m *MessageError) Parent() error

Parent 父级错误

Jump to

Keyboard shortcuts

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