-
Notifications
You must be signed in to change notification settings - Fork 50
/
errors.go
52 lines (43 loc) · 1.32 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
46
47
48
49
50
51
52
package errors
type (
// ErrUnauthorized describes an unauthorized request.
ErrUnauthorized struct{}
// ErrBadRequest describes a malformed / invalid request.
ErrBadRequest struct{}
// ErrForbidden describes a forbidden request.
ErrForbidden struct{}
// ErrNotFound describes an error when no corresponding resources could be found.
ErrNotFound struct{}
// ErrMultipleResults describes an error when multiple
// resources were found by an API call that should return only one.
ErrMultipleResults struct{}
// ErrInternalErrors describes a generic error that led to an internal server error.
ErrInternalErrors struct{}
)
const (
ErrUnauthorizedMsg = "unauthorized"
ErrBadRequestMsg = "bad request"
ErrForbiddenMsg = "forbidden"
ErrNotFoundMsg = "not found"
ErrMultipleResultsMsg = "multiple results found"
ErrInternalErrorsMsg = "internal server error"
)
// Error returns the error message.
func (e *ErrUnauthorized) Error() string {
return ErrUnauthorizedMsg
}
func (e *ErrBadRequest) Error() string {
return ErrBadRequestMsg
}
func (e *ErrForbidden) Error() string {
return ErrForbiddenMsg
}
func (e *ErrNotFound) Error() string {
return ErrNotFoundMsg
}
func (e *ErrMultipleResults) Error() string {
return ErrMultipleResultsMsg
}
func (e *ErrInternalErrors) Error() string {
return ErrInternalErrorsMsg
}