Documentation
¶
Overview ¶
Package erro 收拢了所有的错误类型,错误溯源类型等 1. 支持打印不同该类型的错误的详细提示, 方便确定问题的解决方法 2. 异常可以溯源, 方便问题排查
Index ¶
- Variables
- func Cause(err error) error
- func CauseBy(err error, traceAbleError Traceable) bool
- func NewArgNotFoundError(funcName string, index int) error
- func NewArgsNotMatchError(funcDef interface{}, argLen int, expectLen int) error
- func NewFieldNotFoundError(typName string, fieldName string) error
- func NewFuncNotFoundError(funcName string) error
- func NewFuncNotFoundErrorWithSuggestion(funcName string, suggestions []string) error
- func NewIllegalCallError(funcName string, paramName string, paramValue string) error
- func NewIllegalParamCError(paramName string, paramValue string, cause error) error
- func NewIllegalParamError(paramName string, paramValue string) error
- func NewIllegalParamTypeError(paramName string, paramType, expectType string) error
- func NewIllegalStatusError(funcName string, msg string) error
- func NewReturnParamNotFoundError(funcName string, index int) error
- func NewReturnsNotMatchError(funcDef interface{}, argLen int, expectLen int) error
- func NewTraceableError(err error, cause error) error
- func NewTraceableErrorc(errStr string, cause error) error
- func NewTraceableErrors(errStr string) error
- func NewTypeNotFoundError(typName string) error
- type ArgNotFound
- type ArgsNotMatch
- type FieldNotFound
- type Frame
- type FuncNotFound
- type IllegalParam
- type IllegalParamType
- type IllegalStatus
- type RequiredBuildFlags
- type ReturnParamNotFound
- type ReturnsNotMatch
- type Traceable
- type TraceableError
- type TypeNotFound
Constants ¶
This section is empty.
Variables ¶
var GcFlags = NewRequiredBuildFlagsError("-gcflags=\"all=-l\"")
GcFlags 编译标记,取消函数内联
var LdFlags = NewRequiredBuildFlagsError("-ld=flags=\"-s=false\"")
LdFlags 编译标记,取消符号压缩
Functions ¶
func CauseBy ¶ added in v1.0.5
CauseBy 判断错误是否由指定的异常引起,err对象需要实现Traceable接口才能被追踪, 否则一律返回false err 判断目标异常 traceAbleError 指定的异常原因
func NewArgNotFoundError ¶
NewArgNotFoundError 函数未找到 funcName 函数名称 index 参数下标
func NewArgsNotMatchError ¶
NewArgsNotMatchError 创建参数异常 funcDef 函数定义 argLen 参数长度 expectLen 期望长度
func NewFieldNotFoundError ¶
NewFieldNotFoundError 创建类型未找到异常 typName 类型名称 fieldName 属性名称
func NewFuncNotFoundError ¶
NewFuncNotFoundError 函数未找到 funcName 函数名称
func NewFuncNotFoundErrorWithSuggestion ¶
NewFuncNotFoundErrorWithSuggestion 函数未找到并给出提示 funcName 函数名称
func NewIllegalCallError ¶
NewIllegalCallError 创建参数异常 funcName 函数名 paramName 参数名 paramValue 参数值
func NewIllegalParamCError ¶
NewIllegalParamCError 创建参数异常 paramName 参数名 paramValue 参数值
func NewIllegalParamError ¶
NewIllegalParamError 创建参数异常 paramName 参数名 paramValue 参数值
func NewIllegalParamTypeError ¶
NewIllegalParamTypeError 创建参数类型异常 paramName 参数名 paramType 参数类型 expectType 期望类型
func NewIllegalStatusError ¶
NewIllegalStatusError 状态参数异常 funcName 函数名 msg 信息
func NewReturnParamNotFoundError ¶
NewReturnParamNotFoundError 函数未找到 funcName 函数名称 index 返回值下标
func NewReturnsNotMatchError ¶
NewReturnsNotMatchError 创建参数异常 funcDef 函数定义 argLen 参数长度 expectLen 期望长度
func NewTraceableError ¶
NewTraceableError 通过 error, cause 描述创建可跟踪的错误
func NewTraceableErrorc ¶ added in v1.0.5
NewTraceableErrorc 通过 string, cause 描述创建可跟踪的错误
func NewTraceableErrors ¶ added in v1.0.5
NewTraceableErrors 通过 string 描述创建可跟踪的错误
func NewTypeNotFoundError ¶
NewTypeNotFoundError 创建类型未找到异常 typName 类型名称
Types ¶
type ArgNotFound ¶
type ArgNotFound struct {
// contains filtered or unexported fields
}
ArgNotFound 参数未找到异常
type ArgsNotMatch ¶
type ArgsNotMatch struct {
// contains filtered or unexported fields
}
ArgsNotMatch 参数不匹配异常
type FieldNotFound ¶
type FieldNotFound struct {
// contains filtered or unexported fields
}
FieldNotFound 类型没有找到
type Frame ¶ added in v1.0.5
type Frame struct {
// Func contains a function name.
Func string
// Line contains a line number.
Line int
// Path contains a file path.
Path string
}
Frame is a single step in stack trace.
func StackTrace ¶ added in v1.0.5
StackTrace returns stack trace of an error. It will be empty if err is not of type Error.
type FuncNotFound ¶
type FuncNotFound struct {
// contains filtered or unexported fields
}
FuncNotFound 函数未找到异常
type IllegalParam ¶
type IllegalParam struct {
// contains filtered or unexported fields
}
IllegalParam 参数错误异常
type IllegalParamType ¶
type IllegalParamType struct {
// contains filtered or unexported fields
}
IllegalParamType 参数类型错误异常
type IllegalStatus ¶
type IllegalStatus struct {
// contains filtered or unexported fields
}
IllegalStatus 状态错误异常
type RequiredBuildFlags ¶ added in v1.0.5
type RequiredBuildFlags struct {
TraceableError
// contains filtered or unexported fields
}
RequiredBuildFlags 编译标记未找到 典型的比如: -gcflags="all=-l", -ldflags="-s=false"
func NewRequiredBuildFlagsError ¶ added in v1.0.5
func NewRequiredBuildFlagsError(flags ...string) *RequiredBuildFlags
NewRequiredBuildFlagsError 创建编译标记未找到异常 flags 编译、链接标记
type ReturnParamNotFound ¶
type ReturnParamNotFound struct {
// contains filtered or unexported fields
}
ReturnParamNotFound 返回值未找到异常
type ReturnsNotMatch ¶
type ReturnsNotMatch struct {
// contains filtered or unexported fields
}
ReturnsNotMatch 返回参数不匹配异常
type Traceable ¶
type Traceable interface {
// Cause 获取错误的原因
Cause() error
// StackTrace 获取错误的堆栈信息
StackTrace() []Frame
}
Traceable 带原因的异常类型 TODO later 可以使用go自带的 %w 功能替代?
type TraceableError ¶
type TraceableError struct {
// contains filtered or unexported fields
}
TraceableError 可跟踪的错误,异常转述包装
func (*TraceableError) StackTrace ¶ added in v1.0.5
func (w *TraceableError) StackTrace() []Frame
type TypeNotFound ¶
type TypeNotFound struct {
// contains filtered or unexported fields
}
TypeNotFound 类型没有找到