Check if err is nil from saveConfig() before switch type - fixes #427

This commit is contained in:
Harshavardhana
2015-04-18 16:51:54 -07:00
parent 16e3cc4729
commit 32d6a2be82
+10 -8
View File
@@ -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.")
}