From 32d6a2be82e41bc522ad2996d7c2c57d6e034b65 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 18 Apr 2015 16:51:47 -0700 Subject: [PATCH] Check if err is nil from saveConfig() before switch type - fixes #427 --- cmd-config.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cmd-config.go b/cmd-config.go index 65e14ad4..fb51394f 100644 --- a/cmd-config.go +++ b/cmd-config.go @@ -268,14 +268,16 @@ func doConfigCmd(ctx *cli.Context) { console.Fatalln("mc: Unable to identify config file path") } err = saveConfig(ctx) - switch iodine.ToError(err).(type) { - case errConfigExists: - log.Debug.Println(iodine.New(err, nil)) - console.Fatalln("mc: Configuration file " + configPath + " already exists") - default: - // unexpected error - log.Debug.Println(iodine.New(err, nil)) - console.Fatalln("mc: Unable to generate config file", configPath) + if err != nil { + switch iodine.ToError(err).(type) { + case errConfigExists: + log.Debug.Println(iodine.New(err, nil)) + console.Fatalln("mc: Configuration file " + configPath + " already exists") + default: + // unexpected error + log.Debug.Println(iodine.New(err, nil)) + console.Fatalln("mc: Unable to generate config file", configPath) + } } console.Infoln("mc: Configuration written to " + configPath + ". Please update your access credentials.") }