Skip to content

Commit

Permalink
去吃http code
Browse files Browse the repository at this point in the history
  • Loading branch information
yumaojun03 committed Aug 31, 2024
1 parent 6e4a008 commit 9d38539
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
12 changes: 2 additions & 10 deletions exception/exception.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,10 @@ func NewAPIExceptionFromString(msg string) *APIException {
return e
}

func IsError(err error, targetError *APIException) bool {
func IsAPIException(err error, bizCode int) bool {
var apiErr *APIException
if errors.As(err, &apiErr) {
return apiErr.BizCode == targetError.BizCode
}
return false
}

func IsAPIException(err error, code int) bool {
var apiErr *APIException
if errors.As(err, &apiErr) {
return apiErr.BizCode == code
return apiErr.BizCode == bizCode
}
return false
}
Expand Down
4 changes: 3 additions & 1 deletion http/gin/response/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@ func Failed(c *gin.Context, err error) {
e.WithNamespace(application.Get().AppName)
}

c.JSON(e.HttpCode, e)
statusCode := e.HttpCode
e.HttpCode = 0
c.JSON(statusCode, e)
}

0 comments on commit 9d38539

Please sign in to comment.