errors

package
v4.3.7 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrorCode

func IsErrorCode(err error, code ErrorCode) bool

IsErrorCode 检查错误是否属于特定错误码

Types

type DBError

type DBError struct {
	Code    ErrorCode              // 错误码
	Op      string                 // 操作名称
	Err     error                  // 原始错误
	Context map[string]interface{} // 上下文信息
	Stack   string                 // 堆栈信息
}

DBError 数据库错误

func New

func New(code ErrorCode, op string, err error, context map[string]interface{}) *DBError

New 创建新的数据库错误

func Wrap

func Wrap(err error, code ErrorCode, op string, context map[string]interface{}) *DBError

Wrap 包装已有错误

func (*DBError) Error

func (e *DBError) Error() string

type ErrorCode

type ErrorCode int

ErrorCode 错误码

const (
	ErrCodeUnknown ErrorCode = iota
	ErrCodeConnection
	ErrCodeTransaction
	ErrCodeQuery
	ErrCodeExecution
	ErrCodeValidation
)

Jump to

Keyboard shortcuts

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