Fix datastore error for inexistent app (#493)

* fix datastore error inexistent app

* fix get route error handling

* fix API errors handling and tests
This commit is contained in:
Pedro Nasser
2017-01-26 20:41:18 -02:00
committed by Travis Reeder
parent 5a91710dbf
commit a80fe9c897
15 changed files with 65 additions and 100 deletions

View File

@@ -90,13 +90,8 @@ func (s *Server) handleRouteCreate(c *gin.Context) {
}
route, err := s.Datastore.InsertRoute(ctx, wroute.Route)
if err == models.ErrRoutesAlreadyExists {
log.WithError(err).Debug(models.ErrRoutesCreate)
c.JSON(http.StatusConflict, simpleError(models.ErrRoutesAlreadyExists))
return
} else if err != nil {
log.WithError(err).Error(models.ErrRoutesCreate)
c.JSON(http.StatusInternalServerError, simpleError(ErrInternalServerError))
if err != nil {
handleErrorResponse(c, err)
return
}