e

package
v1.8.8 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeOk            = 0 // Success
	CodeServerErr     = 1 // 服务器错误
	CodeParamNotValid = 2 // 参数验证失败
)

Common err code

View Source
const (
	MsgServerErr = "server err"
)

Variables

This section is empty.

Functions

func DefaultSysErr

func DefaultSysErr() error

DefaultSysErr 默认系统错误,即提供默认的错误码,和错误描述

func NewCodeErrf

func NewCodeErrf(code int, format string, a ...any) error

NewCodeErrf 自定义Code码的错误消息

func NewParamErrf

func NewParamErrf(format string, a ...any) error

NewParamErrf 参数类型错误,自定义消息内容,支持格式化内容

func NewSysErrf

func NewSysErrf(format string, a ...any) error

NewSysErrf 系统类型错误,支持自定义错误格式

func WithStack

func WithStack(err error) error

WithStack 只提供默认栈封装,不包含其他处理逻辑

func WrapCodeErrf

func WrapCodeErrf(err error, code int, format string, a ...any) error

func WrapDefaultSysErr

func WrapDefaultSysErr(err error) error

func WrapParamErrf

func WrapParamErrf(err error, format string, a ...any) error

func WrapSysErrf

func WrapSysErrf(err error, format string, a ...any) error

Types

type CodeErr

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

func (*CodeErr) Cause

func (e *CodeErr) Cause() error

func (*CodeErr) Code

func (e *CodeErr) Code() int

func (*CodeErr) Error

func (e *CodeErr) Error() string

func (*CodeErr) Format

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

func (*CodeErr) Unwrap

func (e *CodeErr) Unwrap() error

Unwrap provides compatibility for Go 1.13 error chains.

type Frame

type Frame uintptr

Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.

func (Frame) Format

func (f Frame) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%s    source file
%d    source line
%n    function name
%v    equivalent to %s:%d

Format accepts flags that alter the printing of some verbs, as follows:

%+s   function name and path of source file relative to the compile time
      GOPATH separated by \n\t (<funcname>\n\t<path>)
%+v   equivalent to %+s:%d

func (Frame) MarshalText

func (f Frame) MarshalText() ([]byte, error)

MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.

type StackTrace

type StackTrace []Frame

StackTrace is stack of Frames from innermost (newest) to outermost (oldest).

func (StackTrace) Format

func (st StackTrace) Format(s fmt.State, verb rune)

Format formats the stack of Frames according to the fmt.Formatter interface.

%s	lists source files for each Frame in the stack
%v	lists the source file and line number for each Frame in the stack

Format accepts flags that alter the printing of some verbs, as follows:

%+v   Prints filename, function, and line number for each Frame in the stack.

Jump to

Keyboard shortcuts

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