refactor: add exceptions.py module with structured exception hierarchy
- Create exceptions.py with 7 exception types: TwitterError, AuthenticationError,
RateLimitError, NotFoundError, NetworkError, QueryIdError, TwitterAPIError
- Remove inline TwitterAPIError from client.py, import from exceptions module
- Replace RuntimeError('Cannot resolve queryId') with QueryIdError
- Replace RuntimeError('User not found') with NotFoundError
- Update test assertion for new TwitterAPIError message format
This commit is contained in:
@@ -463,7 +463,7 @@ class TestTwitterAPIError:
|
||||
def test_stores_status_code(self):
|
||||
err = TwitterAPIError(429, "Rate limited")
|
||||
assert err.status_code == 429
|
||||
assert str(err) == "Rate limited"
|
||||
assert "Rate limited" in str(err)
|
||||
|
||||
def test_is_runtime_error(self):
|
||||
err = TwitterAPIError(500, "Server error")
|
||||
|
||||
Reference in New Issue
Block a user