Skip to content

Commit 449e5a3

Browse files
authored
Check post data error (#164)
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 <[email protected]>
1 parent 7720f9e commit 449e5a3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/agent/run.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ func gatherAndPostData(ctx context.Context) {
178178
path = "/api/v1/datareadings"
179179
}
180180
res, err := preflightClient.Post(path, bytes.NewBuffer(data))
181+
if err != nil {
182+
log.Fatalf("Failed to post data: %+v", err)
183+
}
181184
if code := res.StatusCode; code < 200 || code >= 300 {
182185
errorContent := ""
183186
body, _ := ioutil.ReadAll(res.Body)

0 commit comments

Comments
 (0)