-
Notifications
You must be signed in to change notification settings - Fork 22
/
error.go
70 lines (55 loc) · 1.68 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
62
63
64
65
66
67
68
69
70
package cloudformation
import (
"strings"
"github.com/giantswarm/microerror"
)
var invalidConfigError = µerror.Error{
Kind: "invalidConfigError",
}
// IsInvalidConfig asserts invalidConfigError.
func IsInvalidConfig(err error) bool {
return microerror.Cause(err) == invalidConfigError
}
var outputNotFoundError = µerror.Error{
Kind: "outputNotFoundError",
}
// IsOutputNotFound asserts outputNotFoundError.
func IsOutputNotFound(err error) bool {
return microerror.Cause(err) == outputNotFoundError
}
var outputsNotAccessibleError = µerror.Error{
Kind: "outputsNotAccessibleError",
}
// IsOutputsNotAccessible asserts outputsNotAccessibleError.
func IsOutputsNotAccessible(err error) bool {
return microerror.Cause(err) == outputsNotAccessibleError
}
var stackNotFoundError = µerror.Error{
Kind: "stackNotFoundError",
}
// IsStackNotFound asserts stackNotFoundError and stack not found errors from
// the upstream's API message.
//
// FIXME: The validation error returned by the CloudFormation API doesn't make
// things easy to check, other than looking for the returned string. There's no
// constant in the AWS golang SDK for defining this string, it comes from the
// service. This is the same in setup/error.go.
func IsStackNotFound(err error) bool {
if err == nil {
return false
}
if strings.Contains(microerror.Cause(err).Error(), "does not exist") {
return true
}
if microerror.Cause(err) == stackNotFoundError {
return true
}
return false
}
var tooManyStacksError = µerror.Error{
Kind: "tooManyStacksError",
}
// IsTooManyStacks asserts tooManyStacksError.
func IsTooManyStacks(err error) bool {
return microerror.Cause(err) == tooManyStacksError
}