-
Notifications
You must be signed in to change notification settings - Fork 396
/
errors.go
112 lines (95 loc) · 2.86 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
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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package config
import "fmt"
// ErrNoSuchApplication means an application couldn't be found within a specific account and region.
type ErrNoSuchApplication struct {
ApplicationName string
AccountID string
Region string
}
// Is returns whether the provided error equals this error.
func (e *ErrNoSuchApplication) Is(target error) bool {
t, ok := target.(*ErrNoSuchApplication)
if !ok {
return false
}
return e.ApplicationName == t.ApplicationName &&
e.AccountID == t.AccountID &&
e.Region == t.Region
}
func (e *ErrNoSuchApplication) Error() string {
return fmt.Sprintf("couldn't find an application named %s in account %s and region %s",
e.ApplicationName, e.AccountID, e.Region)
}
// ErrNoSuchEnvironment means a specific environment couldn't be found in a specific project.
type ErrNoSuchEnvironment struct {
ApplicationName string
EnvironmentName string
}
// Is returns whether the provided error equals this error.
func (e *ErrNoSuchEnvironment) Is(target error) bool {
t, ok := target.(*ErrNoSuchEnvironment)
if !ok {
return false
}
return e.ApplicationName == t.ApplicationName &&
e.EnvironmentName == t.EnvironmentName
}
func (e *ErrNoSuchEnvironment) Error() string {
return fmt.Sprintf("couldn't find environment %s in the application %s",
e.EnvironmentName, e.ApplicationName)
}
// ErrNoSuchService means a specific service couldn't be found in a specific application.
type ErrNoSuchService struct {
App string
Name string
}
// Is returns whether the provided error equals this error.
func (e *ErrNoSuchService) Is(target error) bool {
t, ok := target.(*ErrNoSuchService)
if !ok {
return false
}
return e.App == t.App &&
e.Name == t.Name
}
func (e *ErrNoSuchService) Error() string {
return fmt.Sprintf("couldn't find service %s in the application %s",
e.Name, e.App)
}
// ErrNoSuchJob means a specific job couldn't be found in a specific application.
type ErrNoSuchJob struct {
App string
Name string
}
// Is returns whether the provided error equals this error.
func (e *ErrNoSuchJob) Is(target error) bool {
t, ok := target.(*ErrNoSuchJob)
if !ok {
return false
}
return e.App == t.App &&
e.Name == t.Name
}
func (e *ErrNoSuchJob) Error() string {
return fmt.Sprintf("couldn't find job %s in the application %s",
e.Name, e.App)
}
// errNoSuchWorkload means a workload couldn't be found in a specific application.
type errNoSuchWorkload struct {
App string
Name string
}
// Is returns whether the provided error equals this error
func (e *errNoSuchWorkload) Is(target error) bool {
t, ok := target.(*errNoSuchWorkload)
if !ok {
return false
}
return e.App == t.App &&
e.Name == t.Name
}
func (e *errNoSuchWorkload) Error() string {
return fmt.Sprintf("couldn't find %s in the application %s", e.Name, e.App)
}