1 Star 0 Fork 1

ttpc2008 / BaiduPCS-Go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
errors.go 584 Bytes
一键复制 编辑 原始数据 按行查看 历史
konica 提交于 2018-04-19 22:21 . 优化代码结构
package pcsweb
import (
"fmt"
"github.com/json-iterator/go"
)
// ErrInfo web 错误详情
type ErrInfo struct {
ErrroCode int `json:"error_code"`
ErrorMsg string `json:"error_msg"`
}
func (ei *ErrInfo) Error() string {
return fmt.Sprintf("error code: %d, error message: %s", ei.ErrroCode, ei.ErrorMsg)
}
// JSON 将错误信息打包成 json
func (ei *ErrInfo) JSON() (data []byte) {
var err error
data, err = jsoniter.MarshalIndent(ei, "", " ")
checkErr(err)
return
}
// checkErr 遇到错误就退出
func checkErr(err error) {
if err != nil {
panic(err)
}
}
1
https://gitee.com/ttpc2008/BaiduPCS-Go.git
git@gitee.com:ttpc2008/BaiduPCS-Go.git
ttpc2008
BaiduPCS-Go
BaiduPCS-Go
v3.5.6

搜索帮助