Skip to content

Commit

Permalink
add debugging for unmarshal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
notque committed Aug 28, 2024
1 parent c1a3e3f commit 6368c25
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/api/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package api
import (
"net/http"

"encoding/json"
"fmt"
"math"
"reflect"
Expand Down Expand Up @@ -185,7 +186,14 @@ func (p *v1Provider) ListEvents(res http.ResponseWriter, req *http.Request) {
}
events, total, err := hermes.GetEvents(&filter, indexID, p.keystone, p.storage)
if ReturnError(res, err) {
logg.Error("api.ListEvents: error %s", err)
logg.Error("api.ListEvents: error calling hermes.GetEvents(): %s", err.Error())

// Check for UnmarshalTypeError and log it
var unmarshalErr *json.UnmarshalTypeError
if errors.As(err, &unmarshalErr) {
logg.Error("api.ListEvents: JSON unmarshal error: Type=%v, Value=%v, Offset=%v, Struct=%v, Field=%v",
unmarshalErr.Type, unmarshalErr.Value, unmarshalErr.Offset, unmarshalErr.Struct, unmarshalErr.Field)
}
storageErrorsCounter.Add(1)
return
}
Expand Down

0 comments on commit 6368c25

Please sign in to comment.