1 Star 0 Fork 0

王宇航 / wcenter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
execption.go 524 Bytes
一键复制 编辑 原始数据 按行查看 历史
王宇航 提交于 2024-04-11 16:15 . 修改名字
package execption
import (
"encoding/json"
"fmt"
)
func NewApiException(code int, format string, a ...any) *Exception {
if i := cap(a); i == 0 {
return &Exception{
Code: code,
Messages: fmt.Sprintf(format),
}
} else {
return &Exception{
Code: code,
Messages: fmt.Sprintf(format, a),
}
}
}
var _ error = (*Exception)(nil)
type Exception struct {
Code int
Messages string
}
func (e *Exception) Error() string {
indent, _ := json.MarshalIndent(e, "", " ")
return string(indent)
}
Go
1
https://gitee.com/King_of_Universe_Sailing/MircoCenter.git
git@gitee.com:King_of_Universe_Sailing/MircoCenter.git
King_of_Universe_Sailing
MircoCenter
wcenter
d15be5429ddb

搜索帮助