1 Star 0 Fork 0

庞飞 / multiapp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
errors_code.go 652 Bytes
一键复制 编辑 原始数据 按行查看 历史
庞飞 提交于 2023-10-03 06:37 . 合并config
package errors
import (
"strconv"
)
var (
ErrorNotLogin = NewError(1, "请先登录")
)
func NewError(code int, text string) *CodeError {
return &CodeError{code, text, nil}
}
func NewErrorMsg(text string) *CodeError {
return &CodeError{0, text, nil}
}
func NewErrorData(code int, text string, data interface{}) *CodeError {
return &CodeError{code, text, data}
}
func FromError(err error) *CodeError {
if err == nil {
return nil
}
return &CodeError{0, err.Error(), nil}
}
type CodeError struct {
Code int
Message string
Data interface{}
}
func (e *CodeError) Error() string {
return strconv.Itoa(e.Code) + ": " + e.Message
}
Go
1
https://gitee.com/pangxianfei/multiapp.git
git@gitee.com:pangxianfei/multiapp.git
pangxianfei
multiapp
multiapp
v1.2.3

搜索帮助