render

package
v0.0.0-...-1cc9653 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CauseByLostConnection

func CauseByLostConnection(err error) bool

CauseByLostConnection 字符串匹配方式检查是否为断开连接导致出错

func F

func F(ctx *gin.Context, err error)

F gin失败响应--接管错误处理

func H

func H(code int, msg string, data interface{}) gin.H

H 格式化响应

func LogErr

func LogErr(err error, mark string, isAlert bool)

LogErr 记录错误日志

func LogErrWithGin

func LogErrWithGin(ctx *gin.Context, err error, isAlert bool)

LogErrWithGin 记录错误日志

func S

func S(ctx *gin.Context, data interface{})

S gin成功响应

Types

type CE

type CE int

CE 简单错误码错误

const (
	SuccessCode     = 0
	UnknownError CE = -1 // 未知错误
	// 基础服务错误
	DbError             CE = 100001 // 系统错误
	RedisError          CE = 100002 // 系统错误
	LostConnectionError CE = 100003 // 系统错误

	// 系统/服务错误
	InvalidParams    CE = 101001 // 请求参数错误
	InvalidRequest   CE = 101002 // 请求错误
	SystemBusy       CE = 101003 // 系统繁忙请稍后再试
	DbRecordNotExist CE = 101004 // 数据不存在
	ErrDefineWithMsg CE = 101005 // %s
)

错误码定义:利用go工具链 generate 自动生成错误码映射map

-- 定义CE类型并通过注释给出对应文案

func (CE) Code

func (e CE) Code() int

Code 错误码

func (CE) Error

func (e CE) Error() string

Error 错误信息

func (CE) Wrap

func (e CE) Wrap(err error, args ...interface{}) E

Wrap 包裹一个错误 返回 E

type E

type E struct {
	CE
	// contains filtered or unexported fields
}

E 组合错误

func (E) Error

func (e E) Error() string

Error 错误信息--一般用户日志记录 开发人员使用

func (E) Format

func (e E) Format() string

Format 格式化错误输出给客户端

func (E) Unwrap

func (e E) Unwrap() error

Unwrap 解包

Jump to

Keyboard shortcuts

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