Fix #44: Raise explicit error when API Key is missing

This commit is contained in:
Cameron Yick
2017-12-24 13:19:03 -05:00
committed by Cameron Yick
parent e80b3f6dfd
commit 9dbfbcbdbb
2 changed files with 15 additions and 1 deletions

View File

@@ -60,7 +60,10 @@ class TiingoClient(RestClient):
api_key = self._config['api_key']
except KeyError:
api_key = os.environ.get('TIINGO_API_KEY')
assert(api_key)
if not(api_key):
raise RuntimeError("Tiingo API Key not provided. Please provide"
" via environment variable or config argument.")
self._headers = {
'Authorization': "Token {}".format(api_key),