Skip to content

Commit

Permalink
Return the error if count error
Browse files Browse the repository at this point in the history
  • Loading branch information
hwchiu committed Jun 28, 2018
1 parent f5e037f commit 0fbbfd9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/server/handler_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ func listNetworkHandler(ctx *web.Context) {

count, err := session.Count(entity.NetworkCollectionName, bson.M{})
if err != nil {
logger.Error(err)
response.InternalServerError(req.Request, resp.ResponseWriter, err)
return
}
totalPages := int(math.Ceil(float64(count) / float64(pageSize)))
resp.AddHeader("X-Total-Count", strconv.Itoa(count))
Expand Down
3 changes: 2 additions & 1 deletion src/server/handler_storage_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ func listStorageProvider(ctx *web.Context) {

count, err := session.Count(entity.StorageProviderCollectionName, bson.M{})
if err != nil {
logger.Error(err)
response.InternalServerError(req.Request, resp.ResponseWriter, err)
return
}
totalPages := int(math.Ceil(float64(count) / float64(pageSize)))
resp.AddHeader("X-Total-Count", strconv.Itoa(count))
Expand Down
4 changes: 2 additions & 2 deletions src/server/handler_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"math"
"strconv"

"github.com/linkernetworks/logger"
"github.com/linkernetworks/utils/timeutils"
"github.com/linkernetworks/vortex/src/entity"
response "github.com/linkernetworks/vortex/src/net/http"
Expand Down Expand Up @@ -124,7 +123,8 @@ func listVolume(ctx *web.Context) {

count, err := session.Count(entity.VolumeCollectionName, bson.M{})
if err != nil {
logger.Error(err)
response.InternalServerError(req.Request, resp.ResponseWriter, err)
return
}
totalPages := int(math.Ceil(float64(count) / float64(pageSize)))
resp.AddHeader("X-Total-Count", strconv.Itoa(count))
Expand Down

0 comments on commit 0fbbfd9

Please sign in to comment.