errorx

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewValidationErrorWithDetails

func NewValidationErrorWithDetails(message string, details map[string]string) error

NewValidationErrorWithDetails 带详细信息的验证错误

Types

type CodeError

type CodeError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

CodeError 带错误码的错误

func NewBadRequest

func NewBadRequest(message string) *CodeError

预定义错误构造函数

func NewConflict

func NewConflict(message string) *CodeError

func NewForbidden

func NewForbidden(message string) *CodeError

func NewInternalError

func NewInternalError(message string) *CodeError

func NewNotFound

func NewNotFound(message string) *CodeError

func NewUnauthorized

func NewUnauthorized(message string) *CodeError

func NewValidationError

func NewValidationError(message string) *CodeError

func (*CodeError) Data

func (e *CodeError) Data() (int, interface{})

Data 返回错误的 HTTP 状态码和响应体

func (*CodeError) Error

func (e *CodeError) Error() string

func (*CodeError) ErrorCode

func (e *CodeError) ErrorCode() string

ErrorCode 返回错误码字符串

type ValidationError

type ValidationError struct {
	CodeError
	Details map[string]string `json:"details"`
}

ValidationError 验证错误(包含详细字段信息)

func (*ValidationError) Data

func (e *ValidationError) Data() (int, interface{})

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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