fix: improved message when nonexisting trade is deleted

part of #11967
pull/11968/head
Matthias 10 months ago
parent 14429d449c
commit 60029c2a8b

@ -1094,7 +1094,7 @@ class RPC:
trade = Trade.get_trades(trade_filter=[Trade.id == trade_id]).first()
if not trade:
logger.warning("delete trade: Invalid argument received")
raise RPCException("invalid argument")
raise RPCException(f"Trade with id '{trade_id}' not found.")
# Try cancelling regular order if that exists
for open_order in trade.open_orders:

@ -393,7 +393,7 @@ def test_rpc_delete_trade(mocker, default_conf, fee, markets, caplog, is_short):
freqtradebot.strategy.order_types["stoploss_on_exchange"] = True
create_mock_trades(fee, is_short)
rpc = RPC(freqtradebot)
with pytest.raises(RPCException, match="invalid argument"):
with pytest.raises(RPCException, match="Trade with id '200' not found."):
rpc._rpc_delete("200")
trades = Trade.session.scalars(select(Trade)).all()

Loading…
Cancel
Save