2 Star 2 Fork 7

王布衣 / gox

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
errors.go 556 Bytes
一键复制 编辑 原始数据 按行查看 历史
王布衣 提交于 2024-01-24 15:31 . 删除废弃的代码
package exception
import (
"fmt"
)
type Throwable interface {
error
Code() int
}
type Exception struct {
Throwable
code int
message string
}
// New 创建一个新的错误信息, 包含一个状态码和信息
func New(code int, message string, a ...any) *Exception {
return &Exception{
code: code,
message: fmt.Sprintf(message, a...),
}
}
// 格式化输出错误信息
func (this Exception) Error() string {
return fmt.Sprintf("#%d, message=%s", this.code, this.message)
}
func (this Exception) Code() int {
return this.code
}
Go
1
https://gitee.com/quant1x/gox.git
git@gitee.com:quant1x/gox.git
quant1x
gox
gox
v1.21.1

搜索帮助