Skip to content

Commit

Permalink
fix(#12): skip global error handler when there is no errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
fuqiangdong01 committed Mar 8, 2024
1 parent 3fb3f09 commit b080a3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/handler/error_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ func ErrorHandler() gin.HandlerFunc {
return func(c *gin.Context) {
c.Next()

if len(c.Errors) < 1 {
return
}

err := c.Errors[0].Err

errorResponseBody := NewErrorResponseBody(getErrorCode(err), err.Error())
Expand Down
6 changes: 5 additions & 1 deletion scripts/namespace.http
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ GET http://localhost:8080/namespaces HTTP/1.1
content-type: application/json

### List namespaces by team ID
GET http://localhost:8080/namespaces?filters[namespace_team_id]=team-sapphire
GET http://localhost:8080/namespaces?filters[namespace_team_id]=team-sapphire&filters[namespace_type]=standard
content-type: application/json

### List namespaces by team ID and standard type
GET http://localhost:8080/namespaces?filters[namespace_team_id]=team-sapphire&filters[namespace_type]=standard
content-type: application/json

### List namespaces by standard type
Expand Down

0 comments on commit b080a3b

Please sign in to comment.