From 3661474f65ad790def3607e2ea7fb6943106e9cf Mon Sep 17 00:00:00 2001 From: rogerwelin Date: Sun, 17 May 2020 02:07:03 +0200 Subject: [PATCH] handle fatal errors a bit more gracefully --- pkg/client/load.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/client/load.go b/pkg/client/load.go index 19b762e..a4be154 100644 --- a/pkg/client/load.go +++ b/pkg/client/load.go @@ -35,7 +35,7 @@ func (c *Cassowary) runLoadTest(outPutChan chan<- durationMetrics, workerChan ch if c.FileMode { request, err = http.NewRequest("GET", c.BaseURL+URLitem, nil) if err != nil { - panic(err) + log.Fatalf("%v", err) } } else { switch c.HTTPMethod { @@ -43,18 +43,18 @@ func (c *Cassowary) runLoadTest(outPutChan chan<- durationMetrics, workerChan ch request, err = http.NewRequest("POST", c.BaseURL, bytes.NewBuffer(c.Data)) request.Header.Set("Content-Type", "application/json") if err != nil { - panic(err) + log.Fatalf("%v", err) } case "PUT": request, err = http.NewRequest("PUT", c.BaseURL, bytes.NewBuffer(c.Data)) request.Header.Set("Content-Type", "application/json") if err != nil { - panic(err) + log.Fatalf("%v", err) } default: request, err = http.NewRequest("GET", c.BaseURL, nil) if err != nil { - panic(err) + log.Fatalf("%v", err) } } } @@ -90,7 +90,7 @@ func (c *Cassowary) runLoadTest(outPutChan chan<- durationMetrics, workerChan ch request = request.WithContext(httptrace.WithClientTrace(context.Background(), trace)) resp, err := c.Client.Do(request) if err != nil { - panic(err) + log.Fatalf("%v", err) } if resp != nil { _, err = io.Copy(ioutil.Discard, resp.Body)