Added basic error handling for RetrieveConfigCurrencyPairs

This commit is contained in:
Ryan O'Hara-Reid
2017-04-01 20:38:53 +11:00
committed by Adrian Gallagher
parent 58741e73ef
commit e27260df6b

View File

@@ -205,10 +205,19 @@ func (c *Config) CheckWebserverConfigValues() error {
return nil
}
func (c *Config) RetrieveConfigCurrencyPairs() {
func (c *Config) RetrieveConfigCurrencyPairs() error {
cryptoCurrencies := common.SplitStrings(c.Cryptocurrencies, ",")
fiatCurrencies := common.SplitStrings(currency.DEFAULT_CURRENCIES, ",")
for _, s := range cryptoCurrencies {
_, err := strconv.Atoi(s)
if err != nil && common.StringContains(c.Cryptocurrencies, s) {
continue
} else {
return errors.New("RetrieveConfigCurrencyPairs: Incorrect Crypto-Currency")
}
}
for _, exchange := range c.Exchanges {
if exchange.Enabled {
baseCurrencies := common.SplitStrings(exchange.BaseCurrencies, ",")
@@ -252,6 +261,8 @@ func (c *Config) RetrieveConfigCurrencyPairs() {
}
c.Cryptocurrencies = common.JoinStrings(cryptoCurrencies, ",")
currency.CryptoCurrencies = c.Cryptocurrencies
return nil
}
func (c *Config) ReadConfig() error {