Skip to content

feat: structured OMS error handling with exception hierarchy#158

Open
emmick4 wants to merge 5 commits intomainfrom
feat/oms-error-standardization
Open

feat: structured OMS error handling with exception hierarchy#158
emmick4 wants to merge 5 commits intomainfrom
feat/oms-error-standardization

Conversation

@emmick4
Copy link
Copy Markdown
Member

@emmick4 emmick4 commented Apr 7, 2026

Companion to tpluslabs/tplus-core#953

emmick4 added 4 commits April 7, 2026 13:52
- New tplus/exceptions.py: OmsError base class with subclasses
  (OrderRejected, AuthError, RateLimitError, NotFoundError, ServerError)
- Updated base.py: parse {"error": {...}} response shape, raise typed
  exceptions with code/message/details/retryable fields
- Updated orderbook.py: handle NotFoundError for 404 responses
- 31 new tests for error classification and response parsing
get_user_inventory, get_user_solvency, get_user_margin_info now catch
NotFoundError and return empty results instead of raising, matching the
pre-existing pattern in get_user_orders_for_book. This maintains backward
compatibility for callers that expect empty data for unknown users.
OmsError now inherits from httpx.HTTPStatusError, so existing
except HTTPStatusError blocks in E2E tests and other consumers
continue to work. The .response attribute is always available.
Also catch NotFoundError in get_user_trades/get_user_orders.
@emmick4 emmick4 force-pushed the feat/oms-error-standardization branch from b38ddec to 2561ffc Compare April 7, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants