forked from drone/go-scm
-
Notifications
You must be signed in to change notification settings - Fork 83
/
errors.go
62 lines (49 loc) · 1.43 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
53
54
55
56
57
58
59
60
61
62
package scm
import (
"fmt"
"strings"
)
// MissingUsers is an error specifying the users that could not be unassigned.
type MissingUsers struct {
Users []string
Action string
}
func (m MissingUsers) Error() string {
return fmt.Sprintf("could not %s the following user(s): %s.", m.Action, strings.Join(m.Users, ", "))
}
// ExtraUsers is an error specifying the users that could not be unassigned.
type ExtraUsers struct {
Users []string
Action string
}
func (e ExtraUsers) Error() string {
return fmt.Sprintf("could not %s the following user(s): %s.", e.Action, strings.Join(e.Users, ", "))
}
// UnknownWebhook if the webhook is unknown
type UnknownWebhook struct {
Event string
}
func (e UnknownWebhook) Error() string {
return fmt.Sprintf("Unknown webhook event: %s.", e.Event)
}
// IsUnknownWebhook returns true if the error is an unknown webhook
func IsUnknownWebhook(err error) bool {
_, ok := err.(UnknownWebhook)
return ok
}
// StateCannotBeChanged represents the error that occurs when a resource cannot be changed
type StateCannotBeChanged struct {
Message string
}
func (s StateCannotBeChanged) Error() string {
return s.Message
}
// StateCannotBeChanged implements error
var _ error = (*StateCannotBeChanged)(nil)
// MissingHeader if the webhook has a missing header
type MissingHeader struct {
Header string
}
func (e MissingHeader) Error() string {
return fmt.Sprintf("400 Bad Request: Missing Header: %s", e.Header)
}