xlerror

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NullError  = add(0, "")
	ErrRequest = add(400, "The request is invalid. Please check your input and try again.") // 客户端请求错误
	ErrParams  = add(422, "Invalid parameters. Please check your input and try again.")     // 参数错误
	ErrServer  = add(500, "An internal server error occurred. Please try again later.")     // 服务端错误
)

Functions

func Equal

func Equal(err error, e Error) bool

Equal 两个错误错误码是否一致

Types

type Error

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

func New

func New(code int, msg string) Error

New 创建一个错误

func String

func String(e string) Error

func (Error) Code

func (e Error) Code() int

func (Error) Details

func (e Error) Details() []interface{}

func (Error) Equal

func (e Error) Equal(err error) bool

func (Error) Error

func (e Error) Error() string

func (Error) Message

func (e Error) Message() string

func (Error) Reload

func (e Error) Reload(message string) Error

type Errors

type Errors interface {
	// Error sometimes Error return Code in string form
	Error() string
	// Code get error code.
	Code() int
	// Message get code message.
	Message() string
	// Details get error detail,it may be nil.
	Details() []interface{}
	// Equal for compatible.
	Equal(error) bool
	// Reload Message
	Reload(string) Error
}

func Cause

func Cause(err error) Errors

Cause 解析错误码

func Wrap

func Wrap(err error, message string) Errors

Wrap 对错误描述进行包装

Jump to

Keyboard shortcuts

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