package
0.1.1
Repository: https://github.com/gole-dev/gole.git
Documentation: pkg.go.dev

# README

错误码设计

参考 新浪开放平台 Error code 的设计

错误返回值格式

{
  "code": 10002,
  "message": "Error occurred while binding the request body to the struct."
}

错误代码说明

10002
服务级错误(1为系统级错误)服务模块代码具体错误代码
  • 服务级别错误:1 为系统级错误;2 为普通错误,通常是由用户非法操作引起的
  • 服务模块为两位数:一个大型系统的服务模块通常不超过两位数,如果超过,说明这个系统该拆分了
  • 错误码为两位数:防止一个模块定制过多的错误码,后期不好维护
  • code = 0 说明是正确返回,code > 0 说明是错误返回
  • 错误通常包括系统级错误码和服务级错误码
  • 建议代码中按服务模块将错误分类
  • 错误码均为 >= 0 的数
  • 在本项目中 HTTP Code 固定为 http.StatusOK,错误码通过 code 来表示。

# Functions

DecodeErr 对错误进行解码,返回错误code和错误提示.
No description provided by the author
No description provided by the author
NewError create a error.
ToHTTPStatusCode convert custom error code to http status code and avoid return unknown status code.
ToRPCCode 自定义错误码转换为RPC识别的错误码,避免返回Unknown状态码.

# Variables

nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
nolint: golint.
预定义错误 Common errors.

# Structs

Err represents an error.
Error 返回错误码和消息的结构体 nolint: govet.
No description provided by the author