-
Notifications
You must be signed in to change notification settings - Fork 6
/
errors.go
45 lines (37 loc) · 1.07 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
package quickbooks
import "fmt"
// ErrorObject quickbooks error object
type ErrorObject struct {
Fault fault `json:"Fault"`
Time string `json:"time"`
}
type fault struct {
Error []faultError `json:"Error"`
Type string `json:"type"`
}
type faultError struct {
Message string `json:"Message"`
Detail string `json:"Detail"`
Code string `json:"code"`
Element string `json:"element"`
}
// Error() ErrorObject error interface method
func (e ErrorObject) Error() string {
errStr := fmt.Sprintf("Type: %s Code: %s Message: %s", e.Fault.Type, e.Fault.Error[0].Code, e.Fault.Error[0].Message)
return errStr
}
// SDKError customer error object
type SDKError struct {
Type string
Code string
Message string
}
// Error() SDKError error interface method
func (e SDKError) Error() string {
errStr := fmt.Sprintf("Type: %s Code: %s Message: %s", e.Type, e.Code, e.Message)
return errStr
}
// New creates a new SDKError object
func (e SDKError) New(errorType string, errorCode string, errorMessage string) SDKError {
return SDKError{errorType, errorCode, errorMessage}
}