errors

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause 返回由 errors.New、errors.Wrap、errors.Wrapf 中包裹的 cause error。 error 如果不是上述方法产生的则会返回其本身

func Json

func Json(err error) string

Json 返回 error 序列化为 JSON 的字符串,如果 error 实现了 Json 方法则 调用 Json 方法返回字符串。未实现 Json 方法则返回:

{"cause":err.Error()}

func New

func New(msg string) error

New 创建一个包含堆栈信息的 error

func Wrap

func Wrap(err error) error

Wrap 返回包含堆栈信息的 error

func Wrapf

func Wrapf(err error, format string, args ...any) error

Wrapf 返回包含堆栈信息的 error。format 格式化信息会保存到堆栈信息中

Types

type Jsoner

type Jsoner interface {
	Json() string
}

Jump to

Keyboard shortcuts

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