errors

package
v0.0.0-...-19bee3a Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	New               = xerrors.New
	Is                = xerrors.Is
	As                = xerrors.As
	Unwrap            = xerrors.Unwrap    // 获取内层错误
	Errorf            = xerrors.Errorf    // 获取内层错误
	Append            = multierror.Append // 获取内层错误
	DbMsg             = "数据库服务器错误"
	Casbin            = "权限系统错误"
	Code              = "健壮验证错误"
	ErrForbidden      = New("禁止访问")
	ErrNotFound       = New("资源不存在")
	ErrBadRequest     = New("请求无效")
	ErrUnauthorized   = New("未授权")
	ErrInternalServer = New("服务器错误")
	ErrDatabase       = New("数据库请求错误")
	ErrExistsfail     = New("扩展存储错误")
	ErrCodefail       = New("编码错误")
)

定义通用错误

Functions

func NewBadRequestError

func NewBadRequestError(msg ...string) error

NewBadRequestError 创建请求无效错误

func NewCodeErr

func NewCodeErr(msg ...string) error

NewCodeErr 编码错误

func NewDataErr

func NewDataErr(code int, msg ...string) error

NewDataErr 数据获取错误

func NewFileErr

func NewFileErr(msg ...string) error

NewFileErr 文件错误

func NewForbiddenError

func NewForbiddenError(msg ...string) error

NewForbiddenError 创建资源禁止访问错误

func NewInternalDatabaseError

func NewInternalDatabaseError(msg ...string) error

ErrDatabase 创建数据库错误

func NewInternalServerError

func NewInternalServerError(msg ...string) error

NewInternalServerError 创建服务器错误

func NewMessageError

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

NewMessageError 创建自定义消息错误

func NewNotFoundError

func NewNotFoundError(msg ...string) error

NewNotFoundError 创建资源不存在错误

func NewUnauthorizedError

func NewUnauthorizedError(msg ...string) error

NewUnauthorizedError 创建未授权错误

Types

type MessageError

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

MessageError 自定义消息错误

func (*MessageError) Error

func (e *MessageError) Error() string
func (e *MessageError) MarshalJSON() ([]byte, error) {
	return []byte(fmt.Sprintf(`"%s"`,e.Error())), nil
}

func (*MessageError) Format

func (e *MessageError) Format(f fmt.State, c rune)

func (*MessageError) FormatError

func (e *MessageError) FormatError(p xerrors.Printer) (next error)

func (*MessageError) Parent

func (e *MessageError) Parent() error

Parent 父级错误

func (*MessageError) Unwrap

func (e *MessageError) Unwrap() error

Jump to

Keyboard shortcuts

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