-
Notifications
You must be signed in to change notification settings - Fork 401
/
errors.go
72 lines (58 loc) · 2.04 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
72
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package cloudformation
import (
"fmt"
"strings"
"github.com/aws/aws-sdk-go/aws/awserr"
)
// ErrChangeSetEmpty occurs when the change set does not contain any new or updated resources.
type ErrChangeSetEmpty struct {
cs *changeSet
}
func (e *ErrChangeSetEmpty) Error() string {
return fmt.Sprintf("change set with name %s for stack %s has no changes", e.cs.name, e.cs.stackName)
}
// ErrStackAlreadyExists occurs when a CloudFormation stack already exists with a given name.
type ErrStackAlreadyExists struct {
Name string
Stack *StackDescription
}
func (e *ErrStackAlreadyExists) Error() string {
return fmt.Sprintf("stack %s already exists", e.Name)
}
// ErrStackNotFound occurs when a CloudFormation stack does not exist.
type ErrStackNotFound struct {
name string
}
func (e *ErrStackNotFound) Error() string {
return fmt.Sprintf("stack named %s cannot be found", e.name)
}
// errChangeSetNotExecutable occurs when the change set cannot be executed.
type errChangeSetNotExecutable struct {
cs *changeSet
descr *changeSetDescription
}
func (e *errChangeSetNotExecutable) Error() string {
return fmt.Sprintf("execute change set %s for stack %s because status is %s with reason %s", e.cs.name, e.cs.stackName, e.descr.executionStatus, e.descr.statusReason)
}
// errStackUpdateInProgress occurs when we try to update a stack that's already being updated.
type errStackUpdateInProgress struct {
name string
}
func (e *errStackUpdateInProgress) Error() string {
return fmt.Sprintf("stack %s is currently being updated and cannot be deployed to", e.name)
}
// stackDoesNotExist returns true if the underlying error is a stack doesn't exist.
func stackDoesNotExist(err error) bool {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case "ValidationError":
// A ValidationError occurs if we describe a stack which doesn't exist.
if strings.Contains(aerr.Message(), "does not exist") {
return true
}
}
}
return false
}