Documentation ¶
Index ¶
- Constants
- func DefaultSysErr() error
- func NewCodeErrf(code int, format string, a ...any) error
- func NewParamErrf(format string, a ...any) error
- func NewSysErrf(format string, a ...any) error
- func WithStack(err error) error
- func WrapCodeErrf(err error, code int, format string, a ...any) error
- func WrapDefaultSysErr(err error) error
- func WrapParamErrf(err error, format string, a ...any) error
- func WrapSysErrf(err error, format string, a ...any) error
- type CodeErr
- type Frame
- type StackTrace
Constants ¶
const ( CodeOk = 0 // Success CodeServerErr = 1 // 服务器错误 CodeParamNotValid = 2 // 参数验证失败 )
Common err code
const (
MsgServerErr = "server err"
)
Variables ¶
This section is empty.
Functions ¶
func NewCodeErrf ¶
NewCodeErrf 自定义Code码的错误消息
func NewParamErrf ¶
NewParamErrf 参数类型错误,自定义消息内容,支持格式化内容
func WrapDefaultSysErr ¶
Types ¶
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 ¶
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 ¶
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.