/
notifications.go
125 lines (98 loc) · 3.03 KB
/
notifications.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package clairerror
import (
"fmt"
"github.com/google/uuid"
)
// ErrNoUpdateOperation inidcates that the queried updater has no
// update operations associated.
type ErrNoUpdateOperation struct {
Updater string
}
func (e ErrNoUpdateOperation) Error() string {
return fmt.Sprintf("updater %s has no associated update operations", e.Updater)
}
// ErrBadNotification indicates a notification was malformed.
// The wrapped error will contain further details.
type ErrBadNotification struct {
NotificationID uuid.UUID
E error
}
func (e ErrBadNotification) Error() string {
return fmt.Sprintf("notification associated with id %s is malformed: %v", e.NotificationID, e.E)
}
func (e ErrBadNotification) Unwrap() error {
return e.E
}
// ErrDeleteNotification indicates an error while deleting notifcations.
// The wrapped error will contain further details.
type ErrDeleteNotification struct {
NotificationID uuid.UUID
E error
}
func (e ErrDeleteNotification) Error() string {
return fmt.Sprintf("notifications associated with id %s were not deleted: %v", e.NotificationID, e.E)
}
func (e ErrDeleteNotification) Unwrap() error {
return e.E
}
// ErrNoReceipt is returned when a notification id has no associated Receipt.
type ErrNoReceipt struct {
NotificationID uuid.UUID
}
func (e ErrNoReceipt) Error() string {
return fmt.Sprintf("no receipt exists for notification id %s", e.NotificationID)
}
// ErrReceipt indicates an error retreiving a receipt for referenced notification id.
type ErrReceipt struct {
NotificationID uuid.UUID
E error
}
func (e ErrReceipt) Error() string {
return fmt.Sprintf("failed to retrieve receipt for notification id %s: %v", e.NotificationID, e.E)
}
func (e ErrReceipt) Unwrap() error {
return e.E
}
// ErrCreated indicates an error occured when retrieving created notification ids.
type ErrCreated struct {
E error
}
func (e ErrCreated) Error() string {
return fmt.Sprintf("failed to retrieve created notification ids: %v", e.E)
}
func (e ErrCreated) Unwrap() error {
return e.E
}
// ErrFailed indicates an error occured when retrieving created notification ids.
type ErrFailed struct {
E error
}
func (e ErrFailed) Error() string {
return fmt.Sprintf("failed to retrieve failed notification ids: %v", e.E)
}
func (e ErrFailed) Unwrap() error {
return e.E
}
// ErrPutNotifications indicates an issues occured when persisting a slice of
// computed notifications.
// The wrapped error will contain further details.
type ErrPutNotifications struct {
NotificationID uuid.UUID
E error
}
func (e ErrPutNotifications) Error() string {
return fmt.Sprintf("failed to persist notification associated with id %s: %v", e.NotificationID.String(), e.E)
}
func (e ErrPutNotifications) Unwrap() error {
return e.E
}
// ErrDeliveryFailed indicates a failure to deliver a notification.
type ErrDeliveryFailed struct {
E error
}
func (e ErrDeliveryFailed) Error() string {
return "failed to deliver notification: " + e.E.Error()
}
func (e ErrDeliveryFailed) Unwrap() error {
return e.E
}