diff options
author | uvok | 2025-04-18 17:44:34 +0200 |
---|---|---|
committer | uvok | 2025-04-18 17:44:34 +0200 |
commit | 3346c665e47fcda5ef3216d66174eae815fcd3cd (patch) | |
tree | 0b6ccd852e70d3b0142b2632639b764fdfabf1c0 /trade_queue.py | |
parent | d12498351659dc47063b42df51d1756bcb2bd4fd (diff) |
Addand use TradeNotFound
Diffstat (limited to 'trade_queue.py')
-rw-r--r-- | trade_queue.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/trade_queue.py b/trade_queue.py index c76017a..5e7fb41 100644 --- a/trade_queue.py +++ b/trade_queue.py @@ -4,6 +4,7 @@ from copy import deepcopy from decimal import Decimal from typing import Callable, Deque, List +from exceptions import TradeNotFound from trade import Trade # Set up a dedicated logger for FIFOQueue @@ -131,14 +132,15 @@ class FIFOQueue: Trade: The removed trade. Raises: - ValueError: If no trade matches the predicate or multiple trades are found. + TradeNotFound: If no trade matches the predicate or multiple trades are found. + ValueError: If multiple trades match the predicate. """ # Use filter to find matching trades matching_trades = list(filter(predicate, self.__queue)) if len(matching_trades) == 0: logger.error("No matching trade found for removal.") - raise ValueError("No trade matches the given predicate.") + raise TradeNotFound("No trade matches the given predicate.") elif len(matching_trades) > 1: logger.error("Multiple matching trades found for removal.") raise ValueError( |