chore: simplify error handling in _rpc_list_custom_data

This commit is contained in:
Axel-CH
2025-03-17 17:52:29 -04:00
parent f66d81c4b8
commit 23187f0c41

View File

@@ -1167,16 +1167,15 @@ class RPC:
] ]
results.append({"trade_id": trade.id, "custom_data": formatted_custom_data}) results.append({"trade_id": trade.id, "custom_data": formatted_custom_data})
# Handle case when there is no custom data found across trades. # Handle case when there is no custom data found across trades.
if not results: if not results:
message_details = "found for any open trades." message_details = ""
if key and trade_id: if key:
message_details = f"with key '{key}' found for Trade ID: {trade_id}." message_details += f"with key '{key}' "
elif trade_id: message_details += (
message_details = f"found for Trade ID: {trade_id}." f"found for Trade ID: {trade_id}." if trade_id else "found for any open trades."
elif key: )
message_details = f"with key '{key}' found for any open trades." raise RPCException(f"No custom-data {message_details}")
raise RPCException(f"No custom-data {message_details}")
return results return results