Handle error from stat on data-dir and shorten error message

This commit is contained in:
Kyle Havlovitz 2016-12-14 20:06:00 -05:00 committed by GitHub
parent 6a49edf128
commit 78455621a1

View file

@ -209,10 +209,12 @@ func (c *Command) readConfig() *Config {
return nil
}
if finfo, _ := os.Stat(config.DataDir); !finfo.IsDir() {
c.Ui.Error(fmt.Sprintf("CRITICAL: The data-dir specified at %q is not a directory", config.DataDir))
c.Ui.Error("Consul will refuse to boot without a valid data directory")
c.Ui.Error("Please provide a valid directory and try starting again.")
if finfo, err := os.Stat(config.DataDir); err != nil {
c.Ui.Error(fmt.Sprintf("Error getting data-dir: %s", err))
return nil
} else if !finfo.IsDir() {
c.Ui.Error(fmt.Sprintf("The data-dir specified at %q is not a directory", config.DataDir))
return nil
}
// Ensure all endpoints are unique