Merge pull request #872 from freqtrade/feature/improve-error-handling

improve error handling
This commit is contained in:
Michael Egger
2018-06-08 22:43:37 +02:00
committed by GitHub
4 changed files with 8 additions and 14 deletions

View File

@@ -61,11 +61,9 @@ class Configuration(object):
with open(path) as file:
conf = json.load(file)
except FileNotFoundError:
logger.critical(
'Config file "%s" not found. Please create your config file',
path
)
exit(0)
raise OperationalException(
'Config file "{}" not found!'
' Please create a config file or check whether it exists.'.format(path))
if 'internals' not in conf:
conf['internals'] = {}

View File

@@ -277,7 +277,7 @@ def get_ticker(pair: str, refresh: Optional[bool] = True) -> dict:
'bid': float(data['bid']),
'ask': float(data['ask']),
}
except KeyError as e:
except KeyError:
logger.debug("Could not cache ticker data for %s", pair)
return data
except (ccxt.NetworkError, ccxt.ExchangeError) as e:

View File

@@ -85,7 +85,7 @@ def test_load_config_max_open_trades_zero(default_conf, mocker, caplog) -> None:
assert log_has('Validating configuration ...', caplog.record_tuples)
def test_load_config_file_exception(mocker, caplog) -> None:
def test_load_config_file_exception(mocker) -> None:
"""
Test Configuration._load_config_file() method
"""
@@ -95,12 +95,8 @@ def test_load_config_file_exception(mocker, caplog) -> None:
)
configuration = Configuration(Namespace())
with pytest.raises(SystemExit):
with pytest.raises(OperationalException, match=r'.*Config file "somefile" not found!*'):
configuration._load_config_file('somefile')
assert log_has(
'Config file "somefile" not found. Please create your config file',
caplog.record_tuples
)
def test_load_config(default_conf, mocker) -> None: