-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patherrors.go
48 lines (39 loc) · 1.23 KB
/
errors.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
41
42
43
44
45
46
47
48
package gocardless
import (
"encoding/json"
)
const (
// InvalidMethodError details when a request is passed, but the method is invalid in the current context
InvalidMethodError = `The request Method is invalid`
)
type errorContainer struct {
Error *Error `json:"error"`
}
// Error base exception class for GoCardless API errors.
// API errors will result in of this
type Error struct {
DocumentationURL string `json:"documentation_url"`
Message string `json:"message"`
RequestID string `json:"request_id"`
Details []*ErrorDetail `json:"errors"`
Type string `json:"type"`
Code int `json:"code"`
}
func (err Error) Error() string {
data, _ := json.Marshal(err)
return string(data)
}
// ErrorDetail a struct containing the reason for the errors
type ErrorDetail struct {
Message string `json:"message"`
Field string `json:"field"`
RequestPointer string `json:"request_pointer"`
}
// RateLimitedExceededError rate limit error
type RateLimitedExceededError struct {
}
func (err *RateLimitedExceededError) Error() string {
return `Rate Limit exceeded`
}
// InvalidEnvironment invalid environment exception
type InvalidEnvironment error