结构修改
This commit is contained in:
parent
7598068a19
commit
2dcf8a7e39
|
@ -402,7 +402,7 @@ func (r *AiRouterBiz) handleApiTask(channels chan entitys.Response, c *websocket
|
|||
return
|
||||
}
|
||||
if len(request.Url) == 0 {
|
||||
err = errors.NewBusinessErr("00022", "api地址获取失败")
|
||||
err = errors.NewBusinessErr(422, "api地址获取失败")
|
||||
return
|
||||
}
|
||||
res, err := request.Send()
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
package errorcode
|
||||
|
||||
var (
|
||||
Success = &BusinessErr{code: "0000", message: "成功"}
|
||||
ParamError = &BusinessErr{code: "0001", message: "参数错误"}
|
||||
NotFoundError = &BusinessErr{code: "0004", message: "请求地址未找到"}
|
||||
SystemError = &BusinessErr{code: "0005", message: "系统错误"}
|
||||
Success = &BusinessErr{code: 200, message: "成功"}
|
||||
ParamError = &BusinessErr{code: 401, message: "参数错误"}
|
||||
NotFoundError = &BusinessErr{code: 404, message: "请求地址未找到"}
|
||||
SystemError = &BusinessErr{code: 405, message: "系统错误"}
|
||||
|
||||
SupplierNotFound = &BusinessErr{code: "0006", message: "供应商不存在"}
|
||||
SessionNotFound = &BusinessErr{code: "0007", message: "未找到会话信息"}
|
||||
AuthNotFound = &BusinessErr{code: "0008", message: "身份验证失败"}
|
||||
KeyNotFound = &BusinessErr{code: "0009", message: "身份验证失败"}
|
||||
SysNotFound = &BusinessErr{code: "0010", message: "未找到系统信息"}
|
||||
SupplierNotFound = &BusinessErr{code: 406, message: "供应商不存在"}
|
||||
SessionNotFound = &BusinessErr{code: 407, message: "未找到会话信息"}
|
||||
AuthNotFound = &BusinessErr{code: 408, message: "身份验证失败"}
|
||||
KeyNotFound = &BusinessErr{code: 409, message: "身份验证失败"}
|
||||
SysNotFound = &BusinessErr{code: 410, message: "未找到系统信息"}
|
||||
InvalidParam = &BusinessErr{code: InvalidParamCode, message: "无效参数"}
|
||||
)
|
||||
|
||||
const (
|
||||
InvalidParamCode = "0008"
|
||||
InvalidParamCode = 408
|
||||
)
|
||||
|
||||
type BusinessErr struct {
|
||||
code string
|
||||
code int
|
||||
message string
|
||||
}
|
||||
|
||||
func (e *BusinessErr) Error() string {
|
||||
return e.message
|
||||
}
|
||||
func (e *BusinessErr) Code() string {
|
||||
func (e *BusinessErr) Code() int {
|
||||
return e.code
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ func (e *BusinessErr) Is(target error) bool {
|
|||
}
|
||||
|
||||
// CustomErr 自定义错误
|
||||
func NewBusinessErr(code string, message string) *BusinessErr {
|
||||
func NewBusinessErr(code int, message string) *BusinessErr {
|
||||
return &BusinessErr{code: code, message: message}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package services
|
|||
|
||||
import (
|
||||
errorcode "ai_scheduler/internal/data/error"
|
||||
"net/http"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/log"
|
||||
)
|
||||
|
@ -18,7 +20,7 @@ func handRes(c *fiber.Ctx, _err error, rsp interface{}) error {
|
|||
err = e
|
||||
} else {
|
||||
log.Error(c.UserContext(), "系统错误 error: ", _err)
|
||||
err = errorcode.NewBusinessErr("500", _err.Error())
|
||||
err = errorcode.NewBusinessErr(http.StatusInternalServerError, _err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue