Skip to content

Commit

Permalink
Check post data error (#164)
Browse files Browse the repository at this point in the history
If the server is not running (e.g. localhost) then we get a stack trace
without this. We should check the error.

Eventually, we can implement a more graceful retry policy.

Signed-off-by: Charlie Egan <charlieegan3@users.noreply.github.com>
  • Loading branch information
charlieegan3 authored May 7, 2020
1 parent 7720f9e commit 449e5a3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ func gatherAndPostData(ctx context.Context) {
path = "/api/v1/datareadings"
}
res, err := preflightClient.Post(path, bytes.NewBuffer(data))
if err != nil {
log.Fatalf("Failed to post data: %+v", err)
}
if code := res.StatusCode; code < 200 || code >= 300 {
errorContent := ""
body, _ := ioutil.ReadAll(res.Body)
Expand Down

0 comments on commit 449e5a3

Please sign in to comment.