Documentation
¶
Overview ¶
Package aselerror
这是一个自定义封装的错误处理包,相比原本的 errors 包它有错误代码和灾害等级。 将它用于常见的API系统是最佳的实现,因为在这种系统中我们有时候需要过滤错误, 不能让所有错误都返回到前端,比起使用swich遍历不如直接比较灾害等级之后设置回调消息来得更方便。 - 这个包设计相对比较简单,因此推荐配合 errors 使用,这样还能有堆栈信息。 - aselerror的设计理念就是针对API接口,正常情况下建议请避免使用它
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AselError ¶
type AselError interface {
GetCode() int
GetLevel() int8
GetMessage() string
Error() string
SetMessage(msg string) AselError
SetFMessage(format string, a ...interface{}) AselError
SetCause(err error) AselError
}
func New ¶
func New(message string, opts ...AselOption) AselError
type AselOption ¶
type AselOption func(*aerr)
func WithCause ¶
func WithCause(err error) AselOption
func WithCode ¶
func WithCode(code int) AselOption
func WithLevel ¶
func WithLevel(level int8) AselOption
Click to show internal directories.
Click to hide internal directories.