github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/command/v2/shared/errors.go (about) 1 package shared 2 3 import ( 4 "fmt" 5 "time" 6 7 "code.cloudfoundry.org/cli/util/ui" 8 ) 9 10 type JobFailedError struct { 11 JobGUID string 12 Message string 13 } 14 15 func (_ JobFailedError) Error() string { 16 return "Job ({{.JobGUID}}) failed: {{.Message}}" 17 } 18 19 func (e JobFailedError) Translate(translate func(string, ...interface{}) string) string { 20 return translate(e.Error(), map[string]interface{}{ 21 "Message": e.Message, 22 "JobGUID": e.JobGUID, 23 }) 24 } 25 26 type JobTimeoutError struct { 27 JobGUID string 28 Timeout time.Duration 29 } 30 31 func (_ JobTimeoutError) Error() string { 32 return "Job ({{.JobGUID}}) polling timeout has been reached. The operation may still be running on the CF instance. Your CF operator may have more information." 33 } 34 35 func (e JobTimeoutError) Translate(translate func(string, ...interface{}) string) string { 36 return translate(e.Error(), map[string]interface{}{ 37 "JobGUID": e.JobGUID, 38 }) 39 } 40 41 type OrganizationNotFoundError struct { 42 Name string 43 } 44 45 func (_ OrganizationNotFoundError) Error() string { 46 return "Organization '{{.Name}}' not found." 47 } 48 49 func (e OrganizationNotFoundError) Translate(translate func(string, ...interface{}) string) string { 50 return translate(e.Error(), map[string]interface{}{ 51 "Name": e.Name, 52 }) 53 } 54 55 type SecurityGroupNotFoundError struct { 56 Name string 57 } 58 59 func (_ SecurityGroupNotFoundError) Error() string { 60 return "Security group '{{.Name}}' not found." 61 } 62 63 func (e SecurityGroupNotFoundError) Translate(translate func(string, ...interface{}) string) string { 64 return translate(e.Error(), map[string]interface{}{ 65 "Name": e.Name, 66 }) 67 } 68 69 type SpaceNotFoundError struct { 70 Name string 71 } 72 73 func (_ SpaceNotFoundError) Error() string { 74 return "Space '{{.Name}}' not found." 75 } 76 77 func (e SpaceNotFoundError) Translate(translate func(string, ...interface{}) string) string { 78 return translate(e.Error(), map[string]interface{}{ 79 "Name": e.Name, 80 }) 81 } 82 83 type HTTPHealthCheckInvalidError struct { 84 } 85 86 func (_ HTTPHealthCheckInvalidError) Error() string { 87 return "Health check type must be 'http' to set a health check HTTP endpoint." 88 } 89 90 func (e HTTPHealthCheckInvalidError) Translate(translate func(string, ...interface{}) string) string { 91 return translate(e.Error()) 92 } 93 94 type InvalidRefreshTokenError struct { 95 } 96 97 func (_ InvalidRefreshTokenError) Error() string { 98 return "The token expired, was revoked, or the token ID is incorrect. Please log back in to re-authenticate." 99 } 100 101 func (e InvalidRefreshTokenError) Translate(translate func(string, ...interface{}) string) string { 102 return translate(e.Error()) 103 } 104 105 type StagingFailedNoAppDetectedError struct { 106 Message string 107 BinaryName string 108 } 109 110 func (_ StagingFailedNoAppDetectedError) Error() string { 111 return "Error staging application: {{.Message}}\n\nTIP: Use '{{.BuildpackCommand}}' to see a list of supported buildpacks." 112 } 113 114 func (e StagingFailedNoAppDetectedError) Translate(translate func(string, ...interface{}) string) string { 115 return translate(e.Error(), map[string]interface{}{ 116 "Message": e.Message, 117 "BuildpackCommand": fmt.Sprintf("%s buildpacks", e.BinaryName), 118 }) 119 } 120 121 type StagingFailedError struct { 122 Message string 123 } 124 125 func (_ StagingFailedError) Error() string { 126 return "Error staging application: {{.Message}}" 127 } 128 129 func (e StagingFailedError) Translate(translate func(string, ...interface{}) string) string { 130 return translate(e.Error(), map[string]interface{}{ 131 "Message": e.Message, 132 }) 133 } 134 135 type StagingTimeoutError struct { 136 AppName string 137 Timeout time.Duration 138 } 139 140 func (_ StagingTimeoutError) Error() string { 141 return "{{.AppName}} failed to stage within {{.Timeout}} minutes" 142 } 143 144 func (e StagingTimeoutError) Translate(translate func(string, ...interface{}) string) string { 145 return translate(e.Error(), map[string]interface{}{ 146 "AppName": e.AppName, 147 "Timeout": e.Timeout.Minutes(), 148 }) 149 } 150 151 type UnsuccessfulStartError struct { 152 AppName string 153 BinaryName string 154 } 155 156 func (_ UnsuccessfulStartError) Error() string { 157 return "Start unsuccessful\n\nTIP: use '{{.BinaryName}} logs {{.AppName}} --recent' for more information" 158 } 159 160 func (e UnsuccessfulStartError) Translate(translate func(string, ...interface{}) string) string { 161 return translate(e.Error(), map[string]interface{}{ 162 "AppName": e.AppName, 163 "BinaryName": e.BinaryName, 164 }) 165 } 166 167 type StartupTimeoutError struct { 168 AppName string 169 BinaryName string 170 } 171 172 func (_ StartupTimeoutError) Error() string { 173 return "Start app timeout\n\nTIP: Application must be listening on the right port. Instead of hard coding the port, use the $PORT environment variable.\n\nUse '{{.BinaryName}} logs {{.AppName}} --recent' for more information" 174 } 175 176 func (e StartupTimeoutError) Translate(translate func(string, ...interface{}) string) string { 177 return translate(e.Error(), map[string]interface{}{ 178 "AppName": e.AppName, 179 "BinaryName": e.BinaryName, 180 }) 181 } 182 183 type UploadFailedError struct { 184 Err error 185 } 186 187 func (_ UploadFailedError) Error() string { 188 return "Uploading files have failed after a number of retriest due to: {{.Error}}" 189 } 190 191 func (e UploadFailedError) Translate(translate func(string, ...interface{}) string) string { 192 var message string 193 if err, ok := e.Err.(ui.TranslatableError); ok { 194 message = err.Translate(translate) 195 } else { 196 message = e.Err.Error() 197 } 198 199 return translate(e.Error(), map[string]interface{}{ 200 "Error": message, 201 }) 202 } 203 204 type NoDomainsFoundError struct { 205 } 206 207 func (_ NoDomainsFoundError) Error() string { 208 return fmt.Sprintf("No private or shared domains found in this organization") 209 } 210 211 func (e NoDomainsFoundError) Translate(translate func(string, ...interface{}) string) string { 212 return translate(e.Error()) 213 } 214 215 type RouteInDifferentSpaceError struct { 216 Route string 217 } 218 219 func (e RouteInDifferentSpaceError) Error() string { 220 return "Route {{.Route}} has been registered to another space." 221 } 222 223 func (e RouteInDifferentSpaceError) Translate(translate func(string, ...interface{}) string) string { 224 return translate(e.Error(), map[string]interface{}{ 225 "Route": e.Route, 226 }) 227 } 228 229 type FileChangedError struct { 230 Filename string 231 } 232 233 func (e FileChangedError) Error() string { 234 return "Stopping push: File {{.Filename}} has been modified since the start of push. Validate the correct state of the file and try again." 235 } 236 237 func (e FileChangedError) Translate(translate func(string, ...interface{}) string) string { 238 return translate(e.Error(), map[string]interface{}{ 239 "Filename": e.Filename, 240 }) 241 } 242 243 type EmptyDirectoryError struct { 244 Path string 245 } 246 247 func (e EmptyDirectoryError) Error() string { 248 return "No app files found in '{{.Path}}'" 249 } 250 251 func (e EmptyDirectoryError) Translate(translate func(string, ...interface{}) string) string { 252 return translate(e.Error(), map[string]interface{}{ 253 "Path": e.Path, 254 }) 255 }