forked from evergreen-ci/evergreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_models.go
76 lines (58 loc) · 1.76 KB
/
api_models.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
71
72
73
74
75
76
package thirdparty
import "fmt"
// Infrastructure/communication-related errors
type ResponseReadError struct {
msg string
}
func (re ResponseReadError) Error() string {
return fmt.Sprintf("API response read error: %v", re.msg)
}
type APIUnmarshalError struct {
body, msg string
}
func (ue APIUnmarshalError) Error() string {
return fmt.Sprintf("API response unmarshal error on %v: %v",
ue.body, ue.msg)
}
type APIResponseError struct {
msg string
}
func (are APIResponseError) Error() string {
return fmt.Sprintf("API response error: %v", are.msg)
}
// Configuration-related errors
// This error should be returned when the requested remote configuration file
// can not be found.
type FileNotFoundError struct {
filepath string
}
func (nfe FileNotFoundError) Error() string {
return fmt.Sprintf("Requested file at %v not found", nfe.filepath)
}
func IsFileNotFound(err error) bool {
_, ok := err.(FileNotFoundError)
return ok
}
type FileDecodeError struct {
Message string
}
func (f FileDecodeError) Error() string {
return fmt.Sprintf("file decoding failed: %v", f.Message)
}
type YAMLFormatError struct {
Message string
}
func (y YAMLFormatError) Error() string {
return fmt.Sprintf("invalid configuration file: %v", y.Message)
}
// When attempting to access the some API using authentication, requests may
// return 404 Not Found, instead of 403 Forbidden, under certain circumstances.
// For example, see https://developer.github.com/v3/#authentication.
// This struct should be used for errors in fetching a requested remote config.
type APIRequestError struct {
Message string `json:"message"`
DocumentationUrl string `json:"documentation_url"`
}
func (are APIRequestError) Error() string {
return fmt.Sprintf("API request error: %v", are.Message)
}