Move missing config file warn just before return.

The warning about a missing config file should only be shown after all
other configuration has succeeded so it's not shown when there are invalid
options specified.  Also add a comment about it where its intended
placement is for the future.
This commit is contained in:
Dave Collins 2014-01-10 01:34:50 -06:00
parent d33e9b4165
commit 4f8c2a3aaf

View file

@ -487,13 +487,6 @@ func loadConfig() (*config, []string, error) {
cfg.ConnectPeers = normalizeAddresses(cfg.ConnectPeers, cfg.ConnectPeers = normalizeAddresses(cfg.ConnectPeers,
activeNetParams.peerPort) activeNetParams.peerPort)
// Warn about missing config file after the final command line parse
// succeeds. This prevents the warning on help messages and invalid
// options.
if configFileError != nil {
btcdLog.Warnf("%v", configFileError)
}
cfg.dial = net.Dial cfg.dial = net.Dial
cfg.lookup = net.LookupIP cfg.lookup = net.LookupIP
if cfg.Proxy != "" { if cfg.Proxy != "" {
@ -535,6 +528,13 @@ func loadConfig() (*config, []string, error) {
} }
} }
// Warn about missing config file only after all other configuration is
// done. This prevents the warning on help messages and invalid
// options. Note this should go directly before the return.
if configFileError != nil {
btcdLog.Warnf("%v", configFileError)
}
return &cfg, remainingArgs, nil return &cfg, remainingArgs, nil
} }