aerror

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMessageUnknown           = "未知错误"
	ErrMessageInvalidParam      = "参数错误"
	ErrMessageInvalidToken      = "token错误"
	ErrMessageInvalidSign       = "签名错误"
	ErrMessageInvalidRequest    = "请求错误"
	ErrMessageInvalidResponse   = "响应错误"
	ErrMessageInvalidData       = "数据错误"
	ErrMessageInvalidState      = "状态错误"
	ErrMessageInvalidOperation  = "操作错误"
	ErrMessageInvalidPermission = "权限错误"
	ErrMessageInvalidUser       = "用户错误"
	ErrMessageInvalidSystem     = "系统错误"
	ErrMessageInvalidService    = "服务错误"
	ErrMessageInvalidNetwork    = "网络错误"
	ErrMessageInvalidDatabase   = "数据库错误"
	ErrMessageInvalidCache      = "缓存错误"
	ErrMessageCacheExpired      = "缓存过期"
	ErrMessageInvalidThirdParty = "第三方错误"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AError

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

func (*AError) Code

func (a *AError) Code() int

func (*AError) Error

func (a *AError) Error() string

func (*AError) Fields

func (a *AError) Fields() []Field

func (*AError) HTTPStatus

func (a *AError) HTTPStatus() int

func (*AError) Message

func (a *AError) Message() string

func (*AError) Stack added in v1.2.0

func (a *AError) Stack() []byte

type CodeType

type CodeType int
const (
	ErrCodeUnknown           CodeType = 10000 + iota // 未知错误码
	ErrCodeInvalidParam                              // 参数错误
	ErrCodeInvalidToken                              // token错误
	ErrCodeInvalidSign                               // 签名错误
	ErrCodeInvalidRequest                            // 请求错误
	ErrCodeInvalidResponse                           // 响应错误
	ErrCodeInvalidData                               // 数据错误
	ErrCodeInvalidState                              // 状态错误
	ErrCodeInvalidOperation                          // 操作错误
	ErrCodeInvalidPermission                         // 权限错误
	ErrCodeInvalidUser                               // 用户错误
	ErrCodeInvalidSystem                             // 系统错误
	ErrCodeInvalidService                            // 服务错误
	ErrCodeInvalidNetwork                            // 网络错误
	ErrCodeInvalidDatabase                           // 数据库错误
	ErrCodeInvalidCache                              // 缓存错误
	ErrCodeCacheExpired                              // 缓存过期
	ErrCodeInvalidThirdParty                         // 第三方错误
)

type Coder

type Coder interface {
	Code() int
}

type Error

type Error interface {
	error
	Coder
	Message
	HTTPStatus
	Fields
	Stacker
}

func New

func New(options ...Option) Error

type Field

type Field struct {
	Key   string
	Value any
}

type Fields

type Fields interface {
	Fields() []Field
}

type HTTPStatus

type HTTPStatus interface {
	HTTPStatus() int
}

type Message

type Message interface {
	Message() string
}

type Option

type Option func(*AError)

func WithCode

func WithCode(code CodeType) Option

func WithCustom added in v1.2.0

func WithCustom(code CodeType, msg string) Option

func WithErr added in v1.2.0

func WithErr(err error) Option

func WithFields

func WithFields(fields ...Field) Option

func WithHTTPStatus

func WithHTTPStatus(httpCode int) Option

func WithMessage

func WithMessage(message string) Option

func WithStack added in v1.2.0

func WithStack(stack []byte) Option

func WithStringer added in v1.2.0

func WithStringer(str fmt.Stringer) Option

type Stacker added in v1.2.0

type Stacker interface {
	Stack() []byte
}

Jump to

Keyboard shortcuts

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