status

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OK 成功状态
	OK int32 = 0

	// UnknownError 未知错误
	UnknownError int32 = -1
)

Variables

This section is empty.

Functions

This section is empty.

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

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 GetStackTrace

func GetStackTrace(skip int) StackTrace

GetStackTrace gets the stack trace.

func PanicStackTrace

func PanicStackTrace() StackTrace

PanicStackTrace gets the panic stack trace.

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.

type Status

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

func New

func New(code int32, msg string, cause ...interface{}) *Status

New 传入错误码,错误消息,错误原因,创建一个状态结构对象

func NewWithStack

func NewWithStack(code int32, msg string, cause ...interface{}) *Status

NewWithStack 传入错误码,错误消息,错误栈堆,创建一个状态结构对象

func (*Status) Cause

func (that *Status) Cause() error

Cause 获取错误原因

func (*Status) Clear

func (that *Status) Clear()

Clear 清除状态结构

func (*Status) Code

func (that *Status) Code() int32

Code 获取错误码

func (*Status) Copy

func (that *Status) Copy(newCause interface{}, newStackSkip ...int) *Status

Copy copy 一个新的状态对象

func (*Status) Format

func (that *Status) Format(state fmt.State, verb rune)

Format 格式化输出

func (*Status) MarshalJSON

func (that *Status) MarshalJSON() ([]byte, error)

MarshalJSON json编码

func (*Status) Msg

func (that *Status) Msg() string

Msg 获取错误消息

func (*Status) OK

func (that *Status) OK() bool

OK 判断状态是否成功

func (*Status) SetCases

func (that *Status) SetCases(cause interface{}) *Status

SetCases 设置错误原因

func (*Status) SetCode

func (that *Status) SetCode(code int32) *Status

SetCode 设置错误码

func (*Status) SetMsg

func (that *Status) SetMsg(msg string) *Status

SetMsg 设置错误消息

func (*Status) StackTrace

func (that *Status) StackTrace() StackTrace

StackTrace 获取错误的栈堆

func (*Status) String

func (that *Status) String() string

把状态对象变成字符串输出

func (*Status) TagStack

func (that *Status) TagStack(skip ...int) *Status

TagStack 栈堆结构

func (*Status) UnknownError

func (that *Status) UnknownError() bool

UnknownError 是否为未知错误

func (*Status) UnmarshalJSON

func (that *Status) UnmarshalJSON(b []byte) error

UnmarshalJSON json解码

Jump to

Keyboard shortcuts

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