errors

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ErrTypeDatabase   = "database"
	ErrTypeWeChat     = "wechat"
	ErrTypeHTTP       = "http"
	ErrTypeConfig     = "config"
	ErrTypeInvalidArg = "invalid_argument"
)

定义错误类型常量

Variables

This section is empty.

Functions

func Err

func Err(c *gin.Context, err error)

Err 在HTTP响应中返回错误

Types

type AppError

type AppError struct {
	Type    string `json:"type"`    // 错误类型
	Message string `json:"message"` // 错误消息
	Cause   error  `json:"-"`       // 原始错误
	Code    int    `json:"-"`       // HTTP Code
}

AppError 表示应用程序错误

func Config

func Config(message string, cause error) *AppError

Config 创建配置错误

func Database

func Database(message string, cause error) *AppError

Database 创建数据库错误

func ErrInvalidArg

func ErrInvalidArg(param string) *AppError

ErrInvalidArg 无效参数错误

func HTTP

func HTTP(message string, cause error) *AppError

HTTP 创建HTTP服务错误

func New

func New(errType, message string, cause error, code int) *AppError

New 创建新的应用错误

func WeChat

func WeChat(message string, cause error) *AppError

WeChat 创建微信相关错误

func (*AppError) Error

func (e *AppError) Error() string

func (*AppError) String

func (e *AppError) String() string

Jump to

Keyboard shortcuts

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