|
|
@ -24,52 +24,53 @@ func (e ErrInfo) Code() int32 {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
ErrNone = ErrInfo{0, ""}
|
|
|
|
ErrNone = ErrInfo{0, "", ""}
|
|
|
|
ErrArgs = ErrInfo{ArgsError, "ArgsError"}
|
|
|
|
ErrArgs = ErrInfo{ArgsError, "ArgsError", ""}
|
|
|
|
ErrDatabase = ErrInfo{DatabaseError, "DatabaseError"}
|
|
|
|
ErrDatabase = ErrInfo{DatabaseError, "DatabaseError", ""}
|
|
|
|
ErrInternalServer = ErrInfo{ServerInternalError, "ServerInternalError"}
|
|
|
|
ErrInternalServer = ErrInfo{ServerInternalError, "ServerInternalError", ""}
|
|
|
|
ErrNetwork = ErrInfo{NetworkError, "NetworkError"}
|
|
|
|
ErrNetwork = ErrInfo{NetworkError, "NetworkError", ""}
|
|
|
|
ErrNoPermission = ErrInfo{NoPermissionError, "NoPermissionError"}
|
|
|
|
ErrNoPermission = ErrInfo{NoPermissionError, "NoPermissionError", ""}
|
|
|
|
|
|
|
|
|
|
|
|
ErrUserIDNotFound = ErrInfo{UserIDNotFoundError, "UserIDNotFoundError"}
|
|
|
|
ErrUserIDNotFound = ErrInfo{UserIDNotFoundError, "UserIDNotFoundError", ""}
|
|
|
|
ErrGroupIDNotFound = ErrInfo{GroupIDNotFoundError, "GroupIDNotFoundError"}
|
|
|
|
ErrGroupIDNotFound = ErrInfo{GroupIDNotFoundError, "GroupIDNotFoundError", ""}
|
|
|
|
|
|
|
|
|
|
|
|
ErrRecordNotFound = ErrInfo{RecordNotFoundError, "RecordNotFoundError"}
|
|
|
|
ErrRecordNotFound = ErrInfo{RecordNotFoundError, "RecordNotFoundError", ""}
|
|
|
|
|
|
|
|
|
|
|
|
ErrRelationshipAlready = ErrInfo{RelationshipAlreadyError, "RelationshipAlreadyError"}
|
|
|
|
ErrRelationshipAlready = ErrInfo{RelationshipAlreadyError, "RelationshipAlreadyError", ""}
|
|
|
|
ErrNotRelationshipYet = ErrInfo{NotRelationshipYetError, "NotRelationshipYetError"}
|
|
|
|
ErrNotRelationshipYet = ErrInfo{NotRelationshipYetError, "NotRelationshipYetError", ""}
|
|
|
|
|
|
|
|
|
|
|
|
ErrOnlyOneOwner = ErrInfo{OnlyOneOwnerError, "OnlyOneOwnerError"}
|
|
|
|
ErrOnlyOneOwner = ErrInfo{OnlyOneOwnerError, "OnlyOneOwnerError", ""}
|
|
|
|
ErrInGroupAlready = ErrInfo{InGroupAlreadyError, "InGroupAlreadyError"}
|
|
|
|
ErrInGroupAlready = ErrInfo{InGroupAlreadyError, "InGroupAlreadyError", ""}
|
|
|
|
ErrNotInGroupYet = ErrInfo{NotInGroupYetError, "NotInGroupYetError"}
|
|
|
|
ErrNotInGroupYet = ErrInfo{NotInGroupYetError, "NotInGroupYetError", ""}
|
|
|
|
ErrDismissedAlready = ErrInfo{DismissedAlreadyError, "DismissedAlreadyError"}
|
|
|
|
ErrDismissedAlready = ErrInfo{DismissedAlreadyError, "DismissedAlreadyError", ""}
|
|
|
|
ErrOwnerNotAllowedQuit = ErrInfo{OwnerNotAllowedQuitError, "OwnerNotAllowedQuitError"}
|
|
|
|
ErrOwnerNotAllowedQuit = ErrInfo{OwnerNotAllowedQuitError, "OwnerNotAllowedQuitError", ""}
|
|
|
|
ErrRegisteredAlready = ErrInfo{RegisteredAlreadyError, "RegisteredAlreadyError"}
|
|
|
|
ErrRegisteredAlready = ErrInfo{RegisteredAlreadyError, "RegisteredAlreadyError", ""}
|
|
|
|
|
|
|
|
|
|
|
|
ErrDefaultOther = ErrInfo{DefaultOtherError, "DefaultOtherError"}
|
|
|
|
ErrDefaultOther = ErrInfo{DefaultOtherError, "DefaultOtherError", ""}
|
|
|
|
ErrData = ErrInfo{DataError, "DataError"}
|
|
|
|
ErrData = ErrInfo{DataError, "DataError", ""}
|
|
|
|
ErrTokenExpired = ErrInfo{TokenExpiredError, "TokenExpiredError"}
|
|
|
|
ErrTokenExpired = ErrInfo{TokenExpiredError, "TokenExpiredError", ""}
|
|
|
|
ErrTokenInvalid = ErrInfo{TokenInvalidError, "TokenInvalidError"} //
|
|
|
|
ErrTokenInvalid = ErrInfo{TokenInvalidError, "TokenInvalidError", ""} //
|
|
|
|
ErrTokenMalformed = ErrInfo{TokenMalformedError, "TokenMalformedError"} //格式错误
|
|
|
|
ErrTokenMalformed = ErrInfo{TokenMalformedError, "TokenMalformedError", ""} //格式错误
|
|
|
|
ErrTokenNotValidYet = ErrInfo{TokenNotValidYetError, "TokenNotValidYetError"} //还未生效
|
|
|
|
ErrTokenNotValidYet = ErrInfo{TokenNotValidYetError, "TokenNotValidYetError", ""} //还未生效
|
|
|
|
ErrTokenUnknown = ErrInfo{TokenUnknownError, "TokenUnknownError"} //未知错误
|
|
|
|
ErrTokenUnknown = ErrInfo{TokenUnknownError, "TokenUnknownError", ""} //未知错误
|
|
|
|
ErrTokenKicked = ErrInfo{TokenKickedError, "TokenKickedError"}
|
|
|
|
ErrTokenKicked = ErrInfo{TokenKickedError, "TokenKickedError", ""}
|
|
|
|
ErrTokenNotExist = ErrInfo{TokenNotExistError, "TokenNotExistError"} //在redis中不存在
|
|
|
|
ErrTokenNotExist = ErrInfo{TokenNotExistError, "TokenNotExistError", ""} //在redis中不存在
|
|
|
|
ErrTokenDifferentPlatformID = ErrInfo{TokenDifferentPlatformIDError, "TokenDifferentPlatformIDError"}
|
|
|
|
ErrTokenDifferentPlatformID = ErrInfo{TokenDifferentPlatformIDError, "TokenDifferentPlatformIDError", ""}
|
|
|
|
ErrTokenDifferentUserID = ErrInfo{TokenDifferentUserIDError, "TokenDifferentUserIDError"}
|
|
|
|
ErrTokenDifferentUserID = ErrInfo{TokenDifferentUserIDError, "TokenDifferentUserIDError", ""}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
//var (
|
|
|
|
func toDetail(err error, info ErrInfo) ErrInfo {
|
|
|
|
// ErrGroupStatusDismissed = errors.New("group dismissed")
|
|
|
|
errInfo := info
|
|
|
|
// ErrNoGroupOwner = errors.New("no group owner")
|
|
|
|
errInfo.WrapErrMsg = err.Error()
|
|
|
|
//)
|
|
|
|
return errInfo
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func ToAPIErrWithErr(err error) ErrInfo {
|
|
|
|
func ToAPIErrWithErr(err error) ErrInfo {
|
|
|
|
switch {
|
|
|
|
switch {
|
|
|
|
case errors.Is(err, gorm.ErrRecordNotFound):
|
|
|
|
case errors.Is(err, gorm.ErrRecordNotFound):
|
|
|
|
return ErrRecordNotFound
|
|
|
|
return toDetail(err, ErrRecordNotFound)
|
|
|
|
case errors.Is(err, ErrArgs):
|
|
|
|
case errors.Is(err, ErrArgs):
|
|
|
|
return ErrArgs
|
|
|
|
return toDetail(err, ErrArgs)
|
|
|
|
case errors.Is(err, ErrDatabase):
|
|
|
|
case errors.Is(err, ErrDatabase):
|
|
|
|
return ErrDatabase
|
|
|
|
return ErrDatabase
|
|
|
|
}
|
|
|
|
}
|
|
|
|