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.
pull/10437/head
Seebs 2018-10-30 19:05:37 -05:00
parent 691dfb8bc1
commit acdb9a6271
1 changed files with 4 additions and 4 deletions

View File

@ -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