Documentation
¶
Index ¶
- Constants
- Variables
- func GetErrorChain() <-chan *ErrorCode
- func GetErrorType(err error) string
- func GetFuncHttpStatus(packageName string, funcName string) (int, bool)
- func ModuleName(goModelfile string) (modName string, err error)
- func SaveCodeInfo()
- func Str2Int(s string, out *int) (err error)
- type Causer
- type CodeInfo
- type ErrorChain
- type ErrorCode
- type Formatter
- func (formatter *Formatter) Frames(frames *runtime.Frames) (codeInfo *CodeInfo)
- func (formatter *Formatter) FuncName2CodeInfo(file string, fullFuncName string, line int) (codeInfo *CodeInfo)
- func (formatter *Formatter) GenerateError(httpStatus int, businessCode string, msg string) (err error)
- func (formatter *Formatter) Msg(msg string, args ...int) (err *ErrorCode)
- func (formatter *Formatter) SendToChain(errorCode *ErrorCode) (err error)
- func (formatter *Formatter) WrapError(err error) (newErr *ErrorCode)
- type GithubComPkgErrors
- type GithubComPkgErrorsStackTracer
Constants ¶
const ( SEPARATOR = '#' WITH_CALL_CHAIN = false SKIP = 2 FORMAT_TPL = "%c%d:%s%c%s" )
Variables ¶
var ErrorMapFile = "errorMapFile.json"
var Exclude []string
var FuncHttpStatusMap map[string]int
var Include []string
var PackageHttpstatusMap map[string]int
Functions ¶
func GetErrorType ¶
func GetFuncHttpStatus ¶
GetFuncHttpStatus 配置每个方法返回错误时,http 默认状态码
func ModuleName ¶
ModuleName help function, get mod package name from go.mod
Types ¶
type ErrorChain ¶
type ErrorChain interface {
Run(fn func() error) ErrorChain
SetError(err error) ErrorChain
Error() error
}
ErrorChain 链式调用
type ErrorCode ¶
type ErrorCode struct {
HttpStatus int `json:"-"`
Code string `json:"code"`
Msg string `json:"msg"`
CodeInfo *CodeInfo
// contains filtered or unexported fields
}
type Formatter ¶
type Formatter struct {
Include []string
Exclude []string
HttpStatus func(packageName string, funcName string) (int, bool)
PCs func(err error, pc []uintptr) (n int)
Cause func(err error) (tagetErr error)
Chan chan<- *ErrorCode
}
func InitErrFormatter ¶
func InitErrFormatter() *Formatter
func (*Formatter) FuncName2CodeInfo ¶
func (formatter *Formatter) FuncName2CodeInfo(file string, fullFuncName string, line int) (codeInfo *CodeInfo)
FuncName2CodeInfo generate *CodeInfo from full function name
func (*Formatter) GenerateError ¶
func (*Formatter) SendToChain ¶
FuncName2CodeInfo generate *CodeInfo from full function name
type GithubComPkgErrors ¶
type GithubComPkgErrors struct{}
GithubComPkgErrors github.com/pkg/errors package implementation
func (*GithubComPkgErrors) Cause ¶
func (pkgErrors *GithubComPkgErrors) Cause(err error) error
Cause implementation (*Formatter).Cause function
type GithubComPkgErrorsStackTracer ¶
type GithubComPkgErrorsStackTracer interface {
StackTrace() errors.StackTrace
}