Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Detect HTTP unexpected EOF errors (#27)
Browse files Browse the repository at this point in the history
Another attempt on handling io.ErrUnexpectedEOF errors.
We can see them in url.Error errors so this change adds those to the
error detection logic.
  • Loading branch information
Bjørn authored Jul 15, 2019
1 parent a22333a commit 9bc0ed3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ func poll(organization org, collector func(org) error) error {
log.Errorf("Collection failed for organization '%s' due timeout", organization.Name)
return nil
}
if httpErr.Err == io.ErrUnexpectedEOF {
log.Errorf("Collection failed for organization '%s' due to unexpected EOF", organization.Name)
return nil
}
}
if err == io.ErrUnexpectedEOF {
log.Errorf("Collection failed for organization '%s' due to unexpected EOF", organization.Name)
Expand Down
9 changes: 9 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ func TestPoll(t *testing.T) {
},
output: nil,
},
{
name: "http unexpected EOF",
collectorErr: &url.Error{
Op: "POST",
URL: "/url",
Err: io.ErrUnexpectedEOF,
},
output: nil,
},
}
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
Expand Down

0 comments on commit 9bc0ed3

Please sign in to comment.