Skip to content

Commit

Permalink
handle fatal errors a bit more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwelin committed May 17, 2020
1 parent 4d20a04 commit 3661474
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/client/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ 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 {
case "POST":
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)
}
}
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3661474

Please sign in to comment.