From ebd516cadba63cf07e8230bcf1602af6708f20bd Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 19 Mar 2024 07:02:48 +0100 Subject: [PATCH] Use combined exception handler at startup --- freqtrade/commands/trade_commands.py | 5 ----- tests/commands/test_commands.py | 7 ++++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/freqtrade/commands/trade_commands.py b/freqtrade/commands/trade_commands.py index 0707cc803..c7f7e524b 100644 --- a/freqtrade/commands/trade_commands.py +++ b/freqtrade/commands/trade_commands.py @@ -23,11 +23,6 @@ def start_trading(args: Dict[str, Any]) -> int: signal.signal(signal.SIGTERM, term_handler) worker = Worker(args) worker.run() - except Exception as e: - logger.error(str(e)) - logger.exception("Fatal exception!") - except (KeyboardInterrupt): - logger.info('SIGINT received, aborting ...') finally: if worker: logger.info("worker found ... calling exit") diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 2252ff9f4..90bd1c270 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -51,15 +51,16 @@ def test_start_trading_fail(mocker, caplog): 'trade', '-c', 'tests/testdata/testconfigs/main_test_config.json' ] - start_trading(get_args(args)) + with pytest.raises(OperationalException): + start_trading(get_args(args)) assert exitmock.call_count == 1 exitmock.reset_mock() caplog.clear() mocker.patch("freqtrade.worker.Worker.__init__", MagicMock(side_effect=OperationalException)) - start_trading(get_args(args)) + with pytest.raises(OperationalException): + start_trading(get_args(args)) assert exitmock.call_count == 0 - assert log_has('Fatal exception!', caplog) def test_start_webserver(mocker, caplog):