Skip to content

Commit

Permalink
return 404 code when delete not exist experiment (#96)
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Caderno <kaderno@gmail.com>
  • Loading branch information
kadern0 committed Oct 8, 2021
1 parent d795cf6 commit 684f94e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/server/httpserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/joomcode/errorx"
"github.com/pingcap/log"
"go.uber.org/zap"
"gorm.io/gorm"

"github.com/chaos-mesh/chaosd/pkg/config"
"github.com/chaos-mesh/chaosd/pkg/core"
Expand Down Expand Up @@ -272,6 +273,10 @@ func (s *httpServer) recoverAttack(c *gin.Context) {
}

func handleError(c *gin.Context, err error) {
if err == gorm.ErrRecordNotFound {
_ = c.AbortWithError(http.StatusNotFound, utils.ErrNotFound.WrapWithNoMessage(err))
return
}
if errorx.IsOfType(err, core.ErrAttackConfigValidation) {
_ = c.AbortWithError(http.StatusBadRequest, utils.ErrInvalidRequest.WrapWithNoMessage(err))
} else {
Expand Down

0 comments on commit 684f94e

Please sign in to comment.