diff --git a/providers/dns/infomaniak/internal/client.go b/providers/dns/infomaniak/internal/client.go index 19d2e81f..5f197624 100644 --- a/providers/dns/infomaniak/internal/client.go +++ b/providers/dns/infomaniak/internal/client.go @@ -153,7 +153,7 @@ func (c *Client) do(req *http.Request) (*APIResponse, error) { } if resp.Result != "success" { - return nil, fmt.Errorf("unexpected API result (%s): %v", resp.Result, resp.ErrResponse) + return nil, fmt.Errorf("%d: unexpected API result (%s): %w", rawResp.StatusCode, resp.Result, resp.ErrResponse) } return &resp, nil diff --git a/providers/dns/infomaniak/internal/models.go b/providers/dns/infomaniak/internal/models.go index 434fa913..7056354d 100644 --- a/providers/dns/infomaniak/internal/models.go +++ b/providers/dns/infomaniak/internal/models.go @@ -1,6 +1,9 @@ package internal -import "encoding/json" +import ( + "encoding/json" + "fmt" +) // Record a DNS record. type Record struct { @@ -28,3 +31,7 @@ type APIErrorResponse struct { Context map[string]string `json:"context,omitempty"` Errors []APIErrorResponse `json:"errors,omitempty"` } + +func (a APIErrorResponse) Error() string { + return fmt.Sprintf("code: %s, description: %s", a.Code, a.Description) +}