-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror_response.go
More file actions
41 lines (34 loc) · 864 Bytes
/
error_response.go
File metadata and controls
41 lines (34 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package gopwa
import (
"fmt"
"strings"
)
// For error format see: http://docs.developer.amazonservices.com/en_US/dev_guide/DG_ResponseFormat.html
// For possible error codes see: https://payments.amazon.co.uk/developer/documentation/apireference/201753060
type ErrorResponse struct {
StatusCode int `xml:"-"`
Errors []Error `xml:"Error"`
RequestID string
}
func (e ErrorResponse) Error() string {
output := fmt.Sprintf(
"gopwa: Error for request '%s' - ",
strings.TrimSpace(e.RequestID),
)
errs := make([]string, len(e.Errors))
for i, err := range e.Errors {
errs[i] = fmt.Sprintf(
"%s: %s",
strings.TrimSpace(err.Code),
strings.TrimSuffix(strings.TrimSpace(err.Message), "."),
)
}
output += strings.Join(errs, ", ")
return output
}
type Error struct {
Type string
Code string
Message string
Detail string
}