Fix error initializing coinmarketcap

This commit is contained in:
xmatthias 2018-05-21 20:01:41 +02:00
parent 13d6297b9f
commit 56e697acf5

View File

@ -8,6 +8,7 @@ import time
from typing import Dict
from coinmarketcap import Market
from requests.exceptions import RequestException
logger = logging.getLogger(__name__)
@ -94,8 +95,8 @@ class CryptoToFiatConverter(object):
coinlistings = self._coinmarketcap.listings()
self._cryptomap = dict(map(lambda coin: (coin["symbol"], str(coin["id"])),
coinlistings["data"]))
except ValueError:
logger.error("Could not load FIAT Cryptocurrency map")
except (ValueError, RequestException) as e:
logger.error("Could not load FIAT Cryptocurrency map for the following problem: %s", e)
def convert_amount(self, crypto_amount: float, crypto_symbol: str, fiat_symbol: str) -> float:
"""