forked from masci/flickr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
35 lines (29 loc) · 795 Bytes
/
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
// Flickr.go error system
package error
// here we define ONLY errors from the library NOT from flickr
// error from flickr have already a code and a message that are returned
// along with the HTTP Response
const (
ApiError = 10
RequestTokenError = 20
OAuthTokenError = 30
)
var errors = map[int]string{
ApiError: "Flickr API returned an error: ",
RequestTokenError: "An error occurred during token request: ",
OAuthTokenError: "An error occurred while getting the OAuth token: ",
}
type Error struct {
ErrorCode int
Message string
}
// Implement error interface
func (e Error) Error() string {
return e.Message
}
func NewError(errorCode int, message string) *Error {
return &Error{
ErrorCode: errorCode,
Message: errors[errorCode] + message,
}
}