errors

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// InternalServerError 服务器异常
	InternalServerError = New("internal server error")

	// NoRecords 没有记录
	NoRecords = New("no records found")

	// NotChange 未改变
	NotChange = New("not change")

	// ParamsInvalid 参数无效
	ParamsInvalid = New("params invalid")
)

Functions

func As

func As(err error, target any) bool

As 查找 err 链中与 target 匹配的第一个错误,如果找到,则将 target 设置为该错误值并返回 true。否则,它将返回 false。

func InIs

func InIs(err error, targets ...error) bool

InIs 报告错误链中的任何错误是否与目标组中其中一个目标匹配。

func Is

func Is(err, target error) bool

Is 报告错误链中的任何错误是否与目标匹配。

func IsEmptyRecord

func IsEmptyRecord(err error) bool

IsEmptyRecord 掺入的错误信息是有找到,但是值为空

func IsNoRecord

func IsNoRecord(err error) bool

IsNoRecord 传入的错误信息是一个没有找到记录的错误

func Unwrap

func Unwrap(err error) error

Unwrap 如果 err 的类型包含返回错误的解包方法,则返回在 err 上调用解包方法的结果。否则,解包将返回 nil。

func Wrap

func Wrap(err error) error

Types

type Error

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

Error 栈错误

func New

func New(message string) *Error

New 生成错误

func (*Error) Cause

func (e *Error) Cause() error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Format

func (e *Error) Format(s fmt.State, verb rune)

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) Wrap

func (e *Error) Wrap(target error) error

Jump to

Keyboard shortcuts

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