-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
31 lines (25 loc) · 1.07 KB
/
Copy pathexceptions.py
File metadata and controls
31 lines (25 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class CryptoAutomationError(Exception):
"""Base exception for all automation-tool-45 errors."""
pass
class ExchangeConnectionError(CryptoAutomationError):
"""Raised when communication with exchange API fails."""
pass
class RateLimitExceeded(CryptoAutomationError):
"""Raised when API request limits are reached."""
pass
class InsufficientFundsError(CryptoAutomationError):
"""Raised when wallet balance is below transaction minimum."""
pass
class OrderPlacementError(CryptoAutomationError):
"""Raised when order execution fails on exchange."""
pass
class ConfigurationError(CryptoAutomationError):
"""Raised for missing or invalid config keys."""
pass
def handle_exception(e: Exception) -> str:
"""Returns standardized error message based on exception type."""
if isinstance(e, RateLimitExceeded):
return "Critical: exchange rate limit hit. Pausing execution."
elif isinstance(e, InsufficientFundsError):
return "Failure: insufficient assets for requested trade."
return f"Unexpected system error: {str(e)}"