1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Switch from fmt.Error* to errors.Error* (#317)

This commit is contained in:
Tom Limoncelli
2018-02-05 16:17:20 -05:00
committed by GitHub
parent 65f8fb63f0
commit 4b1dc82c9b
31 changed files with 162 additions and 140 deletions

View File

@@ -3,10 +3,11 @@ package linode
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"github.com/pkg/errors"
)
const (
@@ -22,7 +23,7 @@ func (c *LinodeApi) fetchDomainList() error {
dr := &domainResponse{}
endpoint := fmt.Sprintf("%s?page=%d", domainsPath, page)
if err := c.get(endpoint, dr); err != nil {
return fmt.Errorf("Error fetching domain list from Linode: %s", err)
return errors.Errorf("Error fetching domain list from Linode: %s", err)
}
for _, domain := range dr.Data {
c.domainIndex[domain.Domain] = domain.ID
@@ -42,7 +43,7 @@ func (c *LinodeApi) getRecords(id int) ([]domainRecord, error) {
dr := &recordResponse{}
endpoint := fmt.Sprintf("%s/%d/records?page=%d", domainsPath, id, page)
if err := c.get(endpoint, dr); err != nil {
return nil, fmt.Errorf("Error fetching record list from Linode: %s", err)
return nil, errors.Errorf("Error fetching record list from Linode: %s", err)
}
records = append(records, dr.Data...)
@@ -173,7 +174,7 @@ func (c *LinodeApi) handleErrors(resp *http.Response) error {
errs := &errorResponse{}
if err := decoder.Decode(errs); err != nil {
return fmt.Errorf("bad status code from Linode: %d not 200. Failed to decode response", resp.StatusCode)
return errors.Errorf("bad status code from Linode: %d not 200. Failed to decode response", resp.StatusCode)
}
buf := bytes.NewBufferString(fmt.Sprintf("bad status code from Linode: %d not 200", resp.StatusCode))