refactor: bubble up error handling so that standard exit codes can be set at the top-level

LogFail shouldn't be called internally if at all possible.
This commit is contained in:
Jose Diaz-Gonzalez
2021-02-03 04:29:57 -05:00
parent ccdbaa84f9
commit d09a7506df
26 changed files with 113 additions and 80 deletions

View File

@@ -515,6 +515,14 @@ func isValidAppNameOld(appName string) error {
return errors.New("App name must begin with lowercase alphanumeric character, and cannot include uppercase characters, or colons")
}
type AppDoesNotExist struct {
appName string
}
func (err *AppDoesNotExist) Error() string {
return fmt.Sprintf("App %s does not exist", err.appName)
}
// VerifyAppName checks if an app conforming to either the old or new
// naming conventions exists
func VerifyAppName(appName string) error {
@@ -526,7 +534,7 @@ func VerifyAppName(appName string) error {
appRoot := AppRoot(appName)
if !DirectoryExists(appRoot) {
return fmt.Errorf("App %s does not exist", appName)
return &AppDoesNotExist{appName}
}
return nil