From 493b6f65920933f09d9d6b48b9d6ee5d327eca5f Mon Sep 17 00:00:00 2001 From: Axel-CH Date: Wed, 12 Mar 2025 00:12:43 -0400 Subject: [PATCH] chore: update api custom-data related routes with better not found error handling --- freqtrade/rpc/api_server/api_v1.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/freqtrade/rpc/api_server/api_v1.py b/freqtrade/rpc/api_server/api_v1.py index 51597b027..1a171e90f 100644 --- a/freqtrade/rpc/api_server/api_v1.py +++ b/freqtrade/rpc/api_server/api_v1.py @@ -226,7 +226,10 @@ def list_open_trades_custom_data( If a key is provided, it will be used to filter data accordingly. Pagination is implemented via the `limit` and `offset` parameters. """ - return rpc._rpc_list_custom_data(key=key, limit=limit, offset=offset) + try: + return rpc._rpc_list_custom_data(key=key, limit=limit, offset=offset) + except RPCException as e: + raise HTTPException(status_code=404, detail=str(e)) @router.get("/trades/{trade_id}/custom-data", response_model=list[ListCustomData], tags=["trading"]) @@ -235,7 +238,10 @@ def list_custom_data(trade_id: int, key: str | None = Query(None), rpc: RPC = De Fetch custom data for a specific trade. If a key is provided, it will be used to filter data accordingly. """ - return rpc._rpc_list_custom_data(trade_id, key=key) + try: + return rpc._rpc_list_custom_data(trade_id, key=key) + except RPCException as e: + raise HTTPException(status_code=404, detail=str(e)) # TODO: Missing response model