Merge pull request #10437 from seebs/seebs/errors

Don't use fmt.Errorf on random strings
pull/10455/head
Jonathan A. Sternberg 2018-11-05 11:39:54 -06:00 committed by GitHub
commit b3d42983b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -161,7 +161,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
}
@ -411,7 +411,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
}
@ -475,11 +475,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