errors

package
v0.0.0-...-53b6486 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTypeRecordNotFound = ErrorType(iota)
	ErrorTypeInvalidRequest
	ErrorTypeServerInternalError
)

Variables

This section is empty.

Functions

func Is

func Is(err error, target error) bool

Types

type Error

type Error interface {
	error

	// GetCode 获取错误代码
	GetCode() string

	// IsType 检查给定的错误是否是某个类型的错误
	IsType(ErrorType) bool

	// Relation 将新的错误关联到当前错误
	// 该方法返回当前错误对象
	Relation(...Error) Error

	// Relations 获取所有关联的错误列表
	Relations() []Error
}

func ErrorInvalidRequest

func ErrorInvalidRequest(code string) Error

func ErrorRecordNotFound

func ErrorRecordNotFound(code string) Error

func ErrorServerInternalError

func ErrorServerInternalError(code string) Error

func New

func New(t ErrorType, code string, message any, params ...any) Error

type ErrorType

type ErrorType int

type I18nError

type I18nError interface {
	// I18n 处理I18N国际化消息
	I18n(ctx context.Context) string
}

func NewI18n

func NewI18n(id string, e Error, params ...string) I18nError

Jump to

Keyboard shortcuts

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