Merge pull request #321 from gcarq/log-exceptions

Log exceptions
This commit is contained in:
Janne Sinivirta 2018-01-06 10:14:57 +02:00 committed by GitHub
commit bcde377019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -145,6 +145,9 @@ def get_signal(pair: str, signal: SignalType) -> bool:
except ValueError as ex:
logger.warning('Unable to analyze ticker for pair %s: %s', pair, str(ex))
return False
except Exception as ex:
logger.exception('Unexpected error when analyzing ticker for pair %s: %s', pair, str(ex))
return False
if dataframe.empty:
return False

View File

@ -57,8 +57,8 @@ def load_config(path: str) -> Dict:
try:
validate(conf, CONF_SCHEMA)
return conf
except ValidationError:
logger.fatal('Configuration is not valid! See config.json.example')
except ValidationError as ex:
logger.fatal('Invalid configuration. See config.json.example. Reason: %s', ex)
raise ValidationError(
best_match(Draft4Validator(CONF_SCHEMA).iter_errors(conf)).message
)

View File

@ -63,3 +63,11 @@ def test_returns_latest_sell_signal(mocker):
return_value=DataFrame([{'sell': 0, 'date': arrow.utcnow()}])
)
assert not get_signal('BTC-ETH', SignalType.SELL)
def test_get_signal_handles_exceptions(mocker):
mocker.patch('freqtrade.analyze.get_ticker_history', return_value=MagicMock())
mocker.patch('freqtrade.analyze.analyze_ticker',
side_effect=Exception('invalid ticker history '))
assert not get_signal('BTC-ETH', SignalType.BUY)