Engine/ExchangeManager: Return error for method GetExchangeByName (#760)

* engine: Add error returns

* engine: after merge fixes

* engine: remove interface

* linter: fix shadow declarations

* engine: fix tests

* niterinos: fixed

* GLORIOUS NITS!
This commit is contained in:
Ryan O'Hara-Reid
2021-08-26 13:09:14 +10:00
committed by GitHub
parent 056a809d93
commit 4851e94eba
18 changed files with 361 additions and 237 deletions

View File

@@ -531,9 +531,9 @@ func GetRelatableCurrencies(p currency.Pair, incOrig, incUSDT bool) currency.Pai
// GetSpecificOrderbook returns a specific orderbook given the currency,
// exchangeName and assetType
func (bot *Engine) GetSpecificOrderbook(p currency.Pair, exchangeName string, assetType asset.Item) (*orderbook.Base, error) {
exch := bot.GetExchangeByName(exchangeName)
if exch == nil {
return nil, ErrExchangeNotFound
exch, err := bot.GetExchangeByName(exchangeName)
if err != nil {
return nil, err
}
return exch.FetchOrderbook(p, assetType)
}
@@ -541,9 +541,9 @@ func (bot *Engine) GetSpecificOrderbook(p currency.Pair, exchangeName string, as
// GetSpecificTicker returns a specific ticker given the currency,
// exchangeName and assetType
func (bot *Engine) GetSpecificTicker(p currency.Pair, exchangeName string, assetType asset.Item) (*ticker.Price, error) {
exch := bot.GetExchangeByName(exchangeName)
if exch == nil {
return nil, ErrExchangeNotFound
exch, err := bot.GetExchangeByName(exchangeName)
if err != nil {
return nil, err
}
return exch.FetchTicker(p, assetType)
}
@@ -661,9 +661,9 @@ func (bot *Engine) GetExchangeCryptocurrencyDepositAddress(exchName, accountID s
return bot.DepositAddressManager.GetDepositAddressByExchangeAndCurrency(exchName, item)
}
exch := bot.GetExchangeByName(exchName)
if exch == nil {
return "", ErrExchangeNotFound
exch, err := bot.GetExchangeByName(exchName)
if err != nil {
return "", err
}
return exch.GetDepositAddress(item, accountID)
}