/
error.go
61 lines (51 loc) · 1.66 KB
/
error.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
package s3object
import (
"strings"
"github.com/giantswarm/microerror"
)
// executionFailedError is an error type for situations where Resource execution
// cannot continue and must always fall back to operatorkit.
//
// This error should never be matched against and therefore there is no matcher
// implement. For further information see:
//
// https://github.com/giantswarm/fmt/blob/master/go/errors.md#matching-errors
//
var executionFailedError = µerror.Error{
Kind: "executionFailedError",
}
var invalidConfigError = µerror.Error{
Kind: "invalidConfigError",
}
// IsInvalidConfig asserts invalidConfigError.
func IsInvalidConfig(err error) bool {
return microerror.Cause(err) == invalidConfigError
}
var wrongTypeError = µerror.Error{
Kind: "wrongTypeError",
}
// IsWrongType asserts wrongTypeError.
func IsWrongType(err error) bool {
return microerror.Cause(err) == wrongTypeError
}
// IsObjectNotFound asserts object not found error from upstream's API message.
func IsObjectNotFound(err error) bool {
if err == nil {
return false
}
return strings.Contains(microerror.Cause(err).Error(), "NoSuchKey: The specified key does not exist")
}
// IsBucketNotFound asserts object not found error from upstream's API message.
func IsBucketNotFound(err error) bool {
if err == nil {
return false
}
return strings.Contains(microerror.Cause(err).Error(), "NoSuchBucket: The specified bucket does not exist")
}
// IsKeyNotFound asserts key not found error from upstream's API message.
func IsKeyNotFound(err error) bool {
if err == nil {
return false
}
return strings.Contains(microerror.Cause(err).Error(), "NotFoundException: Alias arn:aws:kms:")
}