Documentation ¶
Index ¶
- Variables
- func Error(err interface{})
- func IsReqFromHTML(c *gin.Context) bool
- func LogError(err interface{}, tips string)
- func PushErrCodeTextMap(_map ErrorCodeTextInterface)
- func Recover(c *gin.Context)
- func StatusText(code ErrCode) string
- type ErrCode
- type ErrorCodeTextInterface
- type RecoverRenderType
- type Result
Constants ¶
This section is empty.
Variables ¶
View Source
var BuildBy = time.Now()
BuildBy BuildBy
View Source
var DuplicateEntryKey, _ = regexp.Compile(
`Duplicate entry '(.*)' for key '(.*)\.(.*)'`,
)
DuplicateEntryKey DuplicateEntryKey
View Source
var ( ErrCodeTextArray = []ErrorCodeTextInterface{ ErrorCodeText, } )
View Source
var ErrorCodeText = ErrorCodeTextInterface{ Success: "获取成功", Errors: "遇到错误", LoginSuccess: "登陆成功", StatusCreated: "添加成功", AuthedError: "登陆超时", NotFound: "没有数据", RepeatEmail: "邮箱已存在", RepeatUserName: "用户名已存在", BindJSONErr: "绑定失败,请检查参数", InvalidJSONData: "JSON参数错误", InvalidFormData: "Form参数错误", InvalidQueryData: "Url参数错误", NoRoute: "路由不存在", NoMethod: "方法不存在", }
ErrorCodeText 错误提示
View Source
var RecoverErrHtml = false
Functions ¶
func IsReqFromHTML ¶ added in v1.0.8
IsReqFromHTML ReqFromHtml
func PushErrCodeTextMap ¶ added in v1.0.8
func PushErrCodeTextMap(_map ErrorCodeTextInterface)
Types ¶
type ErrCode ¶
type ErrCode int
ErrCode 错误码类型
const ( // Errors 失败 Errors ErrCode = -1 // NoRoute NoRoute NoRoute ErrCode = http.StatusNotFound // NoMethod NoMethod NoMethod ErrCode = http.StatusMethodNotAllowed )
const ( // Success Success Success ErrCode = iota + 240 // LoginSuccess 登陆成功 LoginSuccess StatusCreated ErrCode = http.StatusCreated )
type ErrorCodeTextInterface ¶ added in v1.0.8
type RecoverRenderType ¶ added in v1.0.21
var RecoverRender RecoverRenderType = func(c *gin.Context, code int, result *Result) {
c.HTML(code, "err.html", result)
}
Click to show internal directories.
Click to hide internal directories.