e

package
v1.1.6-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package e

Package e

Package e

Index

Constants

View Source
const CodeBit = 100000

Variables

View Source
var (
	ErrInternalServerError = &ErrCode{Code: 50010000, Message: "服务器内部错误"}
	ErrInvalidParam        = &ErrCode{Code: 40010001, Message: "请求参数不正确"}
	ErrNotFound            = &ErrCode{Code: 40410002, Message: "资源不存在"}
	ErrMethodNotAllow      = &ErrCode{Code: 40510003, Message: "方法不允许"}
)

Functions

func AddCode

func AddCode(m map[ErrorCode]struct{}) error

AddCode business code to codeMessageBox

func Errorf

func Errorf(format string, args ...interface{}) error

Errorf formats according to a format specifier and returns the string as a value that satisfies error. Errorf also records the stack trace at the point it was called.

func New

func New(message string) error

New returns an error with the supplied message. New also records the stack trace at the point it was called.

func Unwrap

func Unwrap(err error) error

func WithStack

func WithStack(err error) error

WithStack annotates err with a stack trace at the point WithStack was called. If err is nil, WithStack returns nil.

func Wrap

func Wrap(err error, message string) error

Wrap returns an error annotating err with a stack trace at the point Wrap is called, and the supplied message. If err is nil, Wrap returns nil.

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Wrapf returns an error annotating err with a stack trace at the point Wrapf is called, and the format specifier. If err is nil, Wrapf returns nil.

Types

type Causer

type Causer interface {
	Cause() error
}

type ErrCode

type ErrCode struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Result  interface{} `json:"result"`
}

ErrCode 规定组成部分为http状态码+5位错误码

func (*ErrCode) Error

func (e *ErrCode) Error() string

func (*ErrCode) ErrorCode

func (e *ErrCode) ErrorCode() int

func (*ErrCode) Msg

func (e *ErrCode) Msg() string

func (*ErrCode) StatusCode

func (e *ErrCode) StatusCode() int

func (*ErrCode) WithMsg

func (e *ErrCode) WithMsg(msg string)

type ErrorCode

type ErrorCode interface {
	error
	StatusCode() int
	ErrorCode() int
	Msg() string
	WithMsg(string)
}

type Errors

type Errors []error

func (Errors) Error

func (s Errors) Error() string

type Frame

type Frame uintptr

Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as an 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.

type UnwrapHandle

type UnwrapHandle interface {
	Unwrap() error
}

Jump to

Keyboard shortcuts

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