errs

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

*

  • @Time : 2020-04-26 19:57
  • @Author : MassAdobe
  • @Description: config

*

*

  • @Time : 2020-04-27 20:14
  • @Author : MassAdobe
  • @Description: error

*

Index

Constants

View Source
const (
	/*error code*/
	SuccessCode                        = 0    // 成功
	ErrSystemCode                      = iota // 内部错误
	ErrNotFoundCode                           // 资源没有找到
	ErrParamCode                              // 输入参数错误
	ErrJsonCode                               // json解析错误
	ErrRedisCode                              // redis错误
	ErrHeaderUserCode                         // 用户基本信息错误
	ErrParamCheckingCode                      // 参数校验错误
	ErrDataBaseCode                           // 数据库错误
	ErrInnerCallingCode                       // 内部调用获取服务错误
	ErrInnerCallingServiceNotFoundCode        // 内部调用服务目标服务不存在错误
	ErrInnerCallingExecCode                   // 内部调用服务错误
	ErrPostRequestCode                        // Post请求错误
	ErrGetRequestCode                         // Get请求错误
	ErrPutRequestCode                         // Put请求错误
	ErrDeleteRequestCode                      // Deleted请求错误
	ErrCopyPropertyCode                       // 实体类转换错误
	ErrRequestTimeoutCode                     // 请求超时
	ErrResponseStatusCode                     // 响应码错误
	ErrGetIdempotentCode                      // 获取幂等token失败
	ErrValidIdempotentCode                    // 校验幂等性失败
	ErrValidIdempotentRepeatCode              // 接口重复提交
	ErrValidIdempotentHeaderCode              // 接口调用非法

	/*error desc*/
	SuccessDesc                        = "成功"
	ErrSystemDesc                      = "内部错误"
	ErrNotFoundDesc                    = "资源没有找到"
	ErrParamDesc                       = "输入参数错误"
	ErrJsonDesc                        = "Json转换错误"
	ErrRedisDesc                       = "redis错误"
	ErrHeaderUserDesc                  = "用户基本信息错误"
	ErrParamCheckingDesc               = "参数校验错误"
	ErrDataBaseDesc                    = "数据库错误"
	ErrInnerCallingDesc                = "内部调用获取服务错误"
	ErrInnerCallingServiceNotFoundDesc = "内部调用服务目标服务不存在错误"
	ErrInnerCallingExecDesc            = "内部调用服务错误"
	ErrPostRequestDesc                 = "Post请求错误"
	ErrGetRequestDesc                  = "Get请求错误"
	ErrPutRequestDesc                  = "Put请求错误"
	ErrDeleteRequestDesc               = "Deleted请求错误"
	ErrCopyPropertyDesc                = "实体类转换错误"
	ErrRequestTimeoutDesc              = "请求超时"
	ErrResponseStatusDesc              = "响应码错误"
	ErrGetIdempotentDesc               = "获取幂等token失败"
	ErrValidIdempotentDesc             = "校验幂等性失败"
	ErrValidIdempotentRepeatDesc       = "接口重复提交"
	ErrValidIdempotentHeaderDesc       = "接口调用非法"
)

*

  • @Author: MassAdobe
  • @TIME: 2020-04-26 21:05
  • @Description: 错误封装

*

Variables

*

  • @Author: MassAdobe
  • @TIME: 2020-04-26 21:06
  • @Description: 错误参数体

*

Functions

func AddErrs added in v1.2.0

func AddErrs(errStructs map[int]string)

*

  • @Author: MassAdobe
  • @TIME: 2020/12/28 5:08 下午
  • @Description: 适配增加宿主项目的错误代码日志

*

func ErrHandler

func ErrHandler() gin.HandlerFunc

*

  • @Author: MassAdobe
  • @TIME: 2020-04-27 20:29
  • @Description: 整体错误处理

*

func HandleNotFound

func HandleNotFound(c *gin.Context)

*

  • @Author: MassAdobe
  • @TIME: 2020-04-27 20:29
  • @Description: 404处理

*

Types

type Error

type Error struct {
	StatusCode int         `json:"status"`
	Code       int         `json:"code"`
	Msg        string      `json:"msg"`
	Data       interface{} `json:"data"`
}

*

  • @Author: MassAdobe
  • @TIME: 2020-04-27 20:14
  • @Description: 错误处理的结构体

*

func BasicNewError

func BasicNewError(status, code int, msg string, err error) *Error

*

  • @Author: MassAdobe
  • @TIME: 2020-04-27 20:20
  • @Description: 基类异常

*

func NewError

func NewError(code int, errs ...error) *Error

*

  • @Author: MassAdobe
  • @TIME: 2020-04-27 20:23
  • @Description: 创建新异常

*

func NewMsgError

func NewMsgError(code int, msg string, errs ...error) *Error

*

  • @Author: MassAdobe
  • @TIME: 2020-04-30 15:57
  • @Description: 创建存在返回值的新异常

*

func NewTimeOutError added in v1.3.0

func NewTimeOutError(code int, errs ...error) *Error

*

  • @Author: MassAdobe
  • @TIME: 2021/1/6 11:03 上午
  • @Description: 创建新超时异常

*

func OtherError

func OtherError(message string) *Error

*

  • @Author: MassAdobe
  • @TIME: 2020-04-27 20:25
  • @Description: 其他错误

*

Jump to

Keyboard shortcuts

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