-
Notifications
You must be signed in to change notification settings - Fork 24
/
errors.go
71 lines (54 loc) · 1.1 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
63
64
65
66
67
68
69
70
71
package services
import (
"net/http"
"github.com/cloudfoundry-incubator/notifications/cf"
)
type MissingKindOrClientError struct {
Err error
}
func (e MissingKindOrClientError) Error() string {
return e.Err.Error()
}
type CriticalKindError struct {
Err error
}
func (e CriticalKindError) Error() string {
return e.Err.Error()
}
type ClientMissingError struct {
Err error
}
func (e ClientMissingError) Error() string {
return e.Err.Error()
}
type KindMissingError struct {
Err error
}
func (e KindMissingError) Error() string {
return e.Err.Error()
}
func CCErrorFor(err error) error {
if failure, ok := err.(cf.Failure); ok {
if failure.Code == http.StatusNotFound {
return CCNotFoundError{err}
}
return CCDownError{err}
}
return err
}
type CCNotFoundError struct {
Err error
}
func (e CCNotFoundError) Error() string {
return e.Err.Error()
}
type CCDownError struct {
Err error
}
func (e CCDownError) Error() string {
return e.Err.Error()
}
type DefaultScopeError struct{}
func (d DefaultScopeError) Error() string {
return "You cannot send a notification to a default scope"
}