forked from focks/apibuildr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfouls.go
49 lines (40 loc) · 867 Bytes
/
fouls.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
package apibuildr
type Foul interface {
Error() string
}
type ApiFoul struct {
ApiName string `json:"api_name"`
Message string `json:"message"`
Cause Foul `json:"-"`
RequestId string `json:"request_id"`
StatusCode int `json:"status_code"`
DomainCode string `json:"domain_codes"`
}
func New(msg string) *ApiFoul {
return &ApiFoul{
Message: msg,
}
}
func (f ApiFoul) Error() string {
return f.Message
}
func (f *ApiFoul) WithCause(cause error) *ApiFoul {
f.Cause = cause
return f
}
func (f *ApiFoul) WithApiName(name string) *ApiFoul {
f.ApiName = name
return f
}
func (f *ApiFoul) WithStatusCode(status int) *ApiFoul {
f.StatusCode = status
return f
}
func (f *ApiFoul) WithDomainCode(code string) *ApiFoul {
f.DomainCode = code
return f
}
func (f *ApiFoul) WithMessage(msg string) *ApiFoul {
f.Message = msg
return f
}