This commit is contained in:
withchao
2023-03-07 12:19:30 +08:00
parent 3fe9ee22fe
commit 4c5613084c
40 changed files with 315 additions and 297 deletions
+21 -21
View File
@@ -1,7 +1,7 @@
package new
import (
"OpenIM/pkg/common/constant"
"OpenIM/pkg/errs"
"errors"
"net/http"
)
@@ -10,35 +10,35 @@ func httpError(ctx *UserConnContext, err error) {
code := http.StatusUnauthorized
ctx.SetHeader("Sec-Websocket-Version", "13")
ctx.SetHeader("ws_err_msg", err.Error())
if errors.Is(err, constant.ErrTokenExpired) {
code = int(constant.ErrTokenExpired.ErrCode)
if errors.Is(err, errs.ErrTokenExpired) {
code = errs.ErrTokenExpired.Code()
}
if errors.Is(err, constant.ErrTokenInvalid) {
code = int(constant.ErrTokenInvalid.ErrCode)
if errors.Is(err, errs.ErrTokenInvalid) {
code = errs.ErrTokenInvalid.Code()
}
if errors.Is(err, constant.ErrTokenMalformed) {
code = int(constant.ErrTokenMalformed.ErrCode)
if errors.Is(err, errs.ErrTokenMalformed) {
code = errs.ErrTokenMalformed.Code()
}
if errors.Is(err, constant.ErrTokenNotValidYet) {
code = int(constant.ErrTokenNotValidYet.ErrCode)
if errors.Is(err, errs.ErrTokenNotValidYet) {
code = errs.ErrTokenNotValidYet.Code()
}
if errors.Is(err, constant.ErrTokenUnknown) {
code = int(constant.ErrTokenUnknown.ErrCode)
if errors.Is(err, errs.ErrTokenUnknown) {
code = errs.ErrTokenUnknown.Code()
}
if errors.Is(err, constant.ErrTokenKicked) {
code = int(constant.ErrTokenKicked.ErrCode)
if errors.Is(err, errs.ErrTokenKicked) {
code = errs.ErrTokenKicked.Code()
}
if errors.Is(err, constant.ErrTokenDifferentPlatformID) {
code = int(constant.ErrTokenDifferentPlatformID.ErrCode)
if errors.Is(err, errs.ErrTokenDifferentPlatformID) {
code = errs.ErrTokenDifferentPlatformID.Code()
}
if errors.Is(err, constant.ErrTokenDifferentUserID) {
code = int(constant.ErrTokenDifferentUserID.ErrCode)
if errors.Is(err, errs.ErrTokenDifferentUserID) {
code = errs.ErrTokenDifferentUserID.Code()
}
if errors.Is(err, constant.ErrConnOverMaxNumLimit) {
code = int(constant.ErrConnOverMaxNumLimit.ErrCode)
if errors.Is(err, errs.ErrConnOverMaxNumLimit) {
code = errs.ErrConnOverMaxNumLimit.Code()
}
if errors.Is(err, constant.ErrConnArgsErr) {
code = int(constant.ErrConnArgsErr.ErrCode)
if errors.Is(err, errs.ErrConnArgsErr) {
code = errs.ErrConnArgsErr.Code()
}
ctx.ErrReturn(err.Error(), code)
}