-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy patherror.go
40 lines (33 loc) · 1.2 KB
/
error.go
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
package paypal
import (
"fmt"
"net/http"
)
const (
ErrTypeValidation = "VALIDATION_ERROR"
ErrTypeInstrumentDeclined = "INSTRUMENT_DECLINED"
ErrTypePaymentAlreadyDone = "PAYMENT_ALREADY_DONE"
)
type ResponseError struct {
Response *http.Response `json:"-"`
Name string `json:"name"`
Message string `json:"message"`
InformationLink string `json:"information_link"`
DebugId string `json:"debug_id"`
Details []ErrorDetail `json:"details"`
}
func (err *ResponseError) Error() string {
return fmt.Sprintf("[%s]%d %s [Name]%s [Message]%s", err.Response.Request.Method, err.Response.StatusCode, err.Response.Request.URL, err.Name, err.Message)
}
type ErrorDetail struct {
Field string `json:"field"`
Issue string `json:"issue"`
}
type IdentityError struct {
Response *http.Response `json:"-"`
Name string `json:"error"`
ErrorDescription string `json:"error_description"`
}
func (err *IdentityError) Error() string {
return fmt.Sprintf("[%s]%d %s [Error]%s [Description]%s", err.Response.Request.Method, err.Response.StatusCode, err.Response.Request.URL, err.Name, err.ErrorDescription)
}