-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherror.go
More file actions
31 lines (23 loc) · 838 Bytes
/
error.go
File metadata and controls
31 lines (23 loc) · 838 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
package openpay
import "fmt"
// Represents service errors
// https://www.openpay.mx/docs/api/#errores
type APIError struct {
// Valid values are: request, internal, gateway
Category string `json:"category,omitempty"`
// Numeric code for the error
// https://www.openpay.mx/docs/api/#c-digos-de-error
Code uint `json:"error_code,omitempty"`
// HTTP request status code
HTTPCode uint `json:"http_code,omitempty"`
// General description
Description string `json:"description,omitempty"`
// Unique identifier for the request
RequestID string `json:"request_id,omitempty"`
// Contains potential fraud flags detected
FraudRules []string `json:"fraud_rules,omitempty"`
}
// Returns a descriptive text representation
func (e *APIError) Error() string {
return fmt.Sprintf("%d: %s - %s", e.Code, e.Category, e.Description)
}