-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_error.go
70 lines (56 loc) · 1.71 KB
/
account_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"fmt"
"form3-accountapi-client/uuid"
)
const (
errMsgInvalidBaseUri string = "baseuri %s is invalid"
errMsgRemoteGatewayFailure string = "remote gateway failure, %s for %s request %s with status %d"
errMsgInvalidRequest string = "remote gateway failure %s for %s request %s"
errMsgAccountNotFound string = "account-id %s and version %d not found"
errMsgDuplicateAccount string = "duplicate account, cannot create with id %v"
errMsgBadAccountRequest string = "field %s is invalid with value %v"
)
type ErrInvalidClientBaseUri struct {
BaseUri string
}
func (e ErrInvalidClientBaseUri) Error() string {
return fmt.Sprintf(errMsgInvalidBaseUri, e.BaseUri)
}
type ErrRemoteGatewayFailure struct {
Method string
BaseUri string
StatusCode int
Message string
}
func (e ErrRemoteGatewayFailure) Error() string {
return fmt.Sprintf(errMsgRemoteGatewayFailure, e.Message, e.Method, e.BaseUri, e.StatusCode)
}
type ErrInvalidRequest struct {
Method string
BaseUri string
ErrMsg string
}
func (e ErrInvalidRequest) Error() string {
return fmt.Sprintf(errMsgInvalidRequest, e.ErrMsg, e.Method, e.BaseUri)
}
type ErrAccountNotFound struct {
AccountId uuid.UUID
AccountVersion int64
}
func (e ErrAccountNotFound) Error() string {
return fmt.Sprintf(errMsgAccountNotFound, e.AccountId, e.AccountVersion)
}
type ErrDuplicateAccount struct {
Account *Account
}
func (e ErrDuplicateAccount) Error() string {
return fmt.Sprintf(errMsgDuplicateAccount, e.Account.Id)
}
type ErrBadAccountRequest struct {
FieldKey string
FieldValue interface{}
}
func (e ErrBadAccountRequest) Error() string {
return fmt.Sprintf(errMsgBadAccountRequest, e.FieldKey, e.FieldValue)
}