mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 22:39:18 +08:00
ctx
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func GinError(c *gin.Context, err error) {
|
||||
c.JSON(http.StatusOK, ApiError(err))
|
||||
c.JSON(http.StatusOK, ParseError(err))
|
||||
}
|
||||
|
||||
func GinSuccess(c *gin.Context, data any) {
|
||||
|
||||
+4
-1
@@ -30,7 +30,7 @@ func isAllFieldsPrivate(v any) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func apiSuccess(data any) *ApiResponse {
|
||||
func ApiSuccess(data any) *ApiResponse {
|
||||
if isAllFieldsPrivate(data) {
|
||||
return &ApiResponse{}
|
||||
}
|
||||
@@ -40,6 +40,9 @@ func apiSuccess(data any) *ApiResponse {
|
||||
}
|
||||
|
||||
func ParseError(err error) *ApiResponse {
|
||||
if err == nil {
|
||||
return ApiSuccess(nil)
|
||||
}
|
||||
unwrap := errs.Unwrap(err)
|
||||
if codeErr, ok := unwrap.(errs.CodeError); ok {
|
||||
resp := ApiResponse{ErrCode: codeErr.Code(), ErrMsg: codeErr.Msg(), ErrDlt: codeErr.Detail()}
|
||||
|
||||
Reference in New Issue
Block a user