-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrors.go
More file actions
45 lines (34 loc) · 952 Bytes
/
Copy patherrors.go
File metadata and controls
45 lines (34 loc) · 952 Bytes
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
package gus
import "strings"
var (
ErrNotAuth = &NotAuthenticatedError{}
ErrNotFound = &NotFoundError{}
ErrCantDeleteSelf = ErrInvalid("You can't delete yourself.")
ErrCantSuspendSelf = ErrInvalid("You can't suspend yourself.")
ErrTokenExpired = ErrInvalid("That access token has expired.")
)
type NotAuthenticatedError struct {
}
func (n *NotAuthenticatedError) Error() string {
return "Not Authenticated"
}
type RateLimitExceededError struct {
Messages []string `json:"messages"`
}
func (rl *RateLimitExceededError) Error() string {
return strings.Join(rl.Messages, "\n- ")
}
type NotFoundError struct {
}
func (n *NotFoundError) Error() string {
return "Not found"
}
func ErrInvalid(messages ...string) error {
return &ValidationError{Messages: messages}
}
type ValidationError struct {
Messages []string `json:"messages"`
}
func (v *ValidationError) Error() string {
return strings.Join(v.Messages, "\n- ")
}