summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJakob Borg <jakob@kastelo.net>2020-04-06 09:53:37 +0200
committerGitHub <noreply@github.com>2020-04-06 09:53:37 +0200
commit88cabb9e0a53a684b1899a20b77b034ecbd75827 (patch)
tree3db872934bd34fb9bfb5b2a404b1b9506c09cc2e /lib
parentb7ba401c0b9aae91b56337bcd8fe7e5b0837e5d7 (diff)
lib/ur: Correct freaky error handling (fixes #6499) (#6500)
Diffstat (limited to 'lib')
-rw-r--r--lib/ur/usage_report.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/ur/usage_report.go b/lib/ur/usage_report.go
index fa65b7307..30282d199 100644
--- a/lib/ur/usage_report.go
+++ b/lib/ur/usage_report.go
@@ -385,15 +385,17 @@ func (s *Service) sendUsageReport(ctx context.Context) error {
},
}
req, err := http.NewRequest("POST", s.cfg.Options().URURL, &b)
- if err == nil {
- req.Header.Set("Content-Type", "application/json")
- req.Cancel = ctx.Done()
- var resp *http.Response
- resp, err = client.Do(req)
- resp.Body.Close()
+ if err != nil {
+ return err
}
-
- return err
+ req.Header.Set("Content-Type", "application/json")
+ req.Cancel = ctx.Done()
+ resp, err := client.Do(req)
+ if err != nil {
+ return err
+ }
+ resp.Body.Close()
+ return nil
}
func (s *Service) serve(ctx context.Context) {