infomaniak: Make error message more meaningful (#1332)
This commit is contained in:
parent
16660b23e4
commit
6d068b5269
2 changed files with 9 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue