forked from jcxplorer/cwlogger
-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors.go
50 lines (43 loc) · 1.34 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
package cwlogger
const (
errCodeDataAlreadyAcceptedException = "DataAlreadyAcceptedException"
errCodeInvalidSequenceTokenException = "InvalidSequenceTokenException"
errCodeThrottlingException = "ThrottlingException"
errCodeInternalFailure = "InternalFailure"
errCodeServiceUnavailable = "ServiceUnavailable"
errCodeServiceUnavailableException = "ServiceUnavailableException"
)
var retryableErrorCodes = map[string]struct{}{
errCodeInvalidSequenceTokenException: {},
errCodeThrottlingException: {},
errCodeInternalFailure: {},
errCodeServiceUnavailable: {},
errCodeServiceUnavailableException: {},
}
// Error contains the AWS error code and message that caused the PutLogEvents
// action to fail. Errors reported by the LogGroup ErrorReporter function may
// be converted into this type.
type Error struct {
Code string
Message string
}
func (err Error) Error() string {
if err.Message == "" {
return err.Code
}
return err.Code + ": " + err.Message
}
func shouldRetry(err error) bool {
if ownErr, ok := err.(Error); ok {
_, found := retryableErrorCodes[ownErr.Code]
return found
}
return true
}
func isErrorCode(err error, code string) bool {
if ownErr, ok := err.(Error); ok {
return ownErr.Code == code
}
return false
}
func noopErrorReporter(error) {}