Skip to content

Commit 706e3a2

Browse files
committed
Better error debugging
1 parent 1b70a4b commit 706e3a2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

api/api.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ type ScalewayAPIError struct {
4141
// Type is a string code that defines the kind of error
4242
Type string `json:"type,omitempty"`
4343

44+
// Fields contains detail about validation error
45+
Fields map[string][]string `json:"fields,omitempty"`
46+
4447
// StatusCode is the HTTP status code received
4548
StatusCode int `json:"-"`
4649

@@ -69,6 +72,11 @@ func (e ScalewayAPIError) Debug() {
6972
"Type": e.Type,
7073
"Message": e.Message,
7174
}).Debug(e.APIMessage)
75+
76+
// error.Fields handling
77+
for k, v := range e.Fields {
78+
log.Debugf(" %-30s %s", fmt.Sprintf("%s: ", k), v)
79+
}
7280
}
7381

7482
// ScalewayIPAddress represents a Scaleway IP address

0 commit comments

Comments
 (0)