errors

package
v1.9.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	OK = iota
	InternalServerErr
	BadRequest
	NotFound
)

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause 获取原始错误

func GetCodeReason

func GetCodeReason(status int) string

func New

func New(status int) error

New

func NewCode

func NewCode(status int, reason string)

func Newf

func Newf(status int, args ...interface{}) error

Newf

func Wrap

func Wrap(err error, status int) error

Wrap

func Wrapf

func Wrapf(err error, status int, args ...interface{}) error

WrapErrorf 支持格式化错误原因

Types

type Code

type Code struct {
	Status int    `json:"status"`
	Reason string `json:"reason"`
}

func GetCode

func GetCode(status int) Code

type Error

type Error struct {
	Err  error
	Code Code
}

func (Error) Error

func (e Error) Error() string

func (Error) GetErrStack

func (e Error) GetErrStack() errors.StackTrace

Jump to

Keyboard shortcuts

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