errors

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error, target interface{}) bool

As Wrapping for errors.As standard library

func Cause

func Cause(err error) error

Cause 返回根因错误

func Code

func Code(err error) code.Code

Code 返回错误码

func Is

func Is(err, target error) bool

Is Wrapping for errors.Is standard library

func New

func New(text string) error

New Wrapping for errors.New standard library

func NewError

func NewError(args ...interface{}) error

NewError 新建一个错误 可传入一下参数: text : 文本字符串 code : 错误码 error: 原生错误

func Next

func Next(err error) error

Next 返回下一个错误

func Replace

func Replace(err error, text string, condition ...code.Code) error

Replace 替换文本

func Stack

func Stack(err error) *stack.Stack

Stack 返回堆栈

func Unwrap

func Unwrap(err error) error

Unwrap Wrapping for errors.Unwrap standard library

Types

type Error

type Error interface {
	error
	// Is 返回当前错误是否等于目标错误
	Is(target error) bool
	// As 返回当前错误是否是某一类错误
	As(target interface{}) bool
	// Code 返回错误码
	Code() code.Code
	// Next 返回下一个错误
	Next() error
	// Cause 返回根因错误
	Cause() error
	// Stack 返回堆栈
	Stack() *stack.Stack
	// Replace 替换文本
	Replace(text string, condition ...code.Code) error
}

Jump to

Keyboard shortcuts

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