From acdb9a62716be2ac179c6da1d6059f39acd81aeb Mon Sep 17 00:00:00 2001 From: Seebs Date: Tue, 30 Oct 2018 19:05:37 -0500 Subject: [PATCH] Don't use fmt.Errorf on random strings In a few places, the client was assuming that an error string would necessarily be safe to pass as a format string. This seems unwise. --- client/v2/client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/v2/client.go b/client/v2/client.go index 6a5c238bcd..ceb34d8c5e 100644 --- a/client/v2/client.go +++ b/client/v2/client.go @@ -157,7 +157,7 @@ func (c *client) Ping(timeout time.Duration) (time.Duration, string, error) { } if resp.StatusCode != http.StatusNoContent { - var err = fmt.Errorf(string(body)) + var err = errors.New(string(body)) return 0, "", err } @@ -407,7 +407,7 @@ func (c *client) Write(bp BatchPoints) error { } if resp.StatusCode != http.StatusNoContent && resp.StatusCode != http.StatusOK { - var err = fmt.Errorf(string(body)) + var err = errors.New(string(body)) return err } @@ -471,11 +471,11 @@ type Response struct { // It returns nil if no errors occurred on any statements. func (r *Response) Error() error { if r.Err != "" { - return fmt.Errorf(r.Err) + return errors.New(r.Err) } for _, result := range r.Results { if result.Err != "" { - return fmt.Errorf(result.Err) + return errors.New(result.Err) } } return nil