Skip to content

Commit

Permalink
get query errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cjimti committed Jun 13, 2019
1 parent 8783695 commit 006153c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion query.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"text/template"
"time"

"github.com/pkg/errors"

"github.com/Masterminds/sprig"
"github.com/gin-gonic/gin"
"github.com/txn2/ack"
Expand Down Expand Up @@ -217,6 +219,9 @@ func (a *Api) ExecuteQueryHandlerF(system bool) gin.HandlerFunc {
a.Logger.Error("EsError", zap.Error(err))
ak.SetPayloadType("EsError")
ak.SetPayload("Error communicating with database.")
//if queryResult != nil {
// ak.SetPayload("Error communicating with database.")
//}
ak.GinErrorAbort(500, "EsError", err.Error())
return
}
Expand Down Expand Up @@ -352,10 +357,15 @@ func (a *Api) GetQuery(account string, id string) (int, *Result, error) {

code, ret, err := a.Elastic.Get(fmt.Sprintf(locFmt, account, IdxQuery, id))
if err != nil {
a.Logger.Error("EsError", zap.Error(err))
a.Logger.Error("EsGetError", zap.Error(err))
return code, nil, err
}

if code != 200 {
a.Logger.Error("EsGetNon200", zap.ByteString("returned", ret))
return code, nil, errors.New(string(ret))
}

queryResult := &Result{}
err = json.Unmarshal(ret, queryResult)
if err != nil {
Expand Down

0 comments on commit 006153c

Please sign in to comment.