From 1510f12efc545a8e442c54812067eee403ddada6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 11 Oct 2014 13:03:11 -0700 Subject: [PATCH] output errors to the proper location in main.go [GH-288] --- CHANGELOG.md | 1 + main.go | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31ffec316..8786fda18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ BUG FIXES: * core: Fix many edge cases surrounding the `count` meta-parameter. * core: Strings in the configuration can escape double-quotes with the standard `\"` syntax. + * core: Error parsing CLI config will show properly. [GH-288] * providers/aws: autoscaling_group can be launched into a vpc [GH-259] * providers/aws: not an error when RDS instance is deleted manually. [GH-307] * providers/aws: Retry deleting subnet for some time while AWS eventually diff --git a/main.go b/main.go index 29ee63743..95eaab560 100644 --- a/main.go +++ b/main.go @@ -88,7 +88,7 @@ func wrappedMain() int { // Load the configuration config := BuiltinConfig if err := config.Discover(); err != nil { - fmt.Fprintf(os.Stderr, "Error discovering plugins: %s", err) + Ui.Error(fmt.Sprintf("Error discovering plugins: %s", err)) return 1 } @@ -123,14 +123,14 @@ func wrappedMain() int { // define extra providers and provisioners. clicfgFile, err := cliConfigFile() if err != nil { - fmt.Fprintf(os.Stderr, "Error loading CLI configuration: \n\n%s\n", err) + Ui.Error(fmt.Sprintf("Error loading CLI configuration: \n\n%s", err)) return 1 } if clicfgFile != "" { usrcfg, err := LoadConfig(clicfgFile) if err != nil { - fmt.Fprintf(os.Stderr, "Error loading CLI configuration: \n\n%s\n", err) + Ui.Error(fmt.Sprintf("Error loading CLI configuration: \n\n%s", err)) return 1 } @@ -143,7 +143,7 @@ func wrappedMain() int { exitCode, err := cli.Run() if err != nil { - fmt.Fprintf(os.Stderr, "Error executing CLI: %s\n", err.Error()) + Ui.Error(fmt.Sprintf("Error executing CLI: %s", err.Error())) return 1 } @@ -155,7 +155,7 @@ func cliConfigFile() (string, error) { configFilePath := os.Getenv("TERRAFORM_CONFIG") if configFilePath == "" { var err error - configFilePath, err = configFile() + configFilePath, err = ConfigFile() mustExist = false if err != nil {