-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
38 lines (24 loc) · 1.23 KB
/
exceptions.py
File metadata and controls
38 lines (24 loc) · 1.23 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
32
33
34
35
36
37
38
"""Custom exception hierarchy for the Hyperliquid trading bot.
Classifies API/network errors so that callers can distinguish between
transient failures (worth retrying) and permanent failures (fail fast).
Hierarchy
---------
HyperliquidBotError
├── TransientError — retryable
│ ├── RateLimitError — 429 / rate-limited
│ └── NetworkError — timeout, connection reset, DNS failure
├── DataError — unexpected response structure or parsing failure
└── ConfigurationError — invalid parameters, signing errors
"""
class HyperliquidBotError(Exception):
"""Base exception for all bot-classified errors."""
class TransientError(HyperliquidBotError):
"""Retryable errors — the same request may succeed later."""
class RateLimitError(TransientError):
"""API rate limit hit (HTTP 429 or equivalent)."""
class NetworkError(TransientError):
"""Connection timeout, reset, DNS failure, etc."""
class DataError(HyperliquidBotError):
"""Unexpected data from the API — missing keys, wrong types, parse failures."""
class ConfigurationError(HyperliquidBotError):
"""Invalid parameters or signing errors — will never succeed without a code change."""