satellite/analytics: improve error logging
This inserts additional information provided in error messages from Hubspot into the Go error that is eventually logged out. Before, we would see the a generic "sending event failed" log. With this change, we will see more detailed information in the log, such as a list of required fields that were not submitted. Change-Id: I24da0646bca62f459377abe6281403020fb54c49
This commit is contained in:
parent
4822b18472
commit
03a8e7c81a
@ -235,14 +235,19 @@ func (q *HubSpotEvents) handleSingleEvent(ctx context.Context, ev HubSpotEvent)
|
||||
}()
|
||||
|
||||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusNoContent {
|
||||
var data struct {
|
||||
type hsError struct {
|
||||
Message string `json:"message"`
|
||||
In string `json:"in"`
|
||||
}
|
||||
var data struct {
|
||||
Message string `json:"message"`
|
||||
Errors []hsError `json:"errors"`
|
||||
}
|
||||
err = json.NewDecoder(resp.Body).Decode(&data)
|
||||
if err != nil {
|
||||
return Error.New("decoding response failed: %w", err)
|
||||
}
|
||||
return Error.New("sending event failed: %s", data.Message)
|
||||
return Error.New("sending event failed: %s - %v", data.Message, data.Errors)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user