Exceptions¶
This page contains the reference for all custom exceptions.
Handling Errors¶
All exceptions raised by seedrcc inherit from the base exception seedrcc.exceptions.SeedrError. This allows you to catch all errors from the library with a single try...except block, while still being able to handle specific error types differently.
Here is a example of how you can handle various exceptions:
import seedrcc
try:
# This operation might fail for various reasons
client.add_torrent("some-magnet-link")
except seedrcc.exceptions.APIError as e:
# Handle specific API errors (e.g., invalid magnet)
print(f"An API error occurred: {e}")
print(f"Error Type: {e.error_type}, Code: {e.code}")
except seedrcc.exceptions.AuthenticationError as e:
# Handle authentication failures (e.g., invalid token)
print(f"An authentication error occurred: {e}")
except seedrcc.exceptions.SeedrError as e:
# Catch any other library-specific errors
print(f"An unexpected error occurred with seedrcc: {e}")
Exception Reference¶
seedrcc.exceptions
¶
SeedrError
¶
Bases: Exception
Base exception for all seedrcc errors.
Source code in seedrcc/exceptions.py
7 8 | |
APIError
¶
Bases: SeedrError
Raised when the API returns an error.
Attributes:
| Name | Type | Description |
|---|---|---|
response |
Optional[Response]
|
The full HTTP response object. |
code |
Optional[int]
|
The custom error code from the API response body. |
error_type |
Optional[str]
|
The type of error from the API response body (e.g., 'parsing_error'). |
Source code in seedrcc/exceptions.py
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 39 | |
ServerError
¶
Bases: SeedrError
Raised for 5xx server-side errors.
Source code in seedrcc/exceptions.py
42 43 44 45 46 47 48 49 50 51 52 53 | |
AuthenticationError
¶
Bases: SeedrError
Raised when authentication or re-authentication fails.
Attributes:
| Name | Type | Description |
|---|---|---|
response |
Optional[Response]
|
The full HTTP response object from the failed auth attempt. |
error_type |
Optional[str]
|
The error type from the API response body (e.g., 'invalid_grant'). |
Source code in seedrcc/exceptions.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
NetworkError
¶
Bases: SeedrError
Raised for network-level errors, such as timeouts or connection problems.
Source code in seedrcc/exceptions.py
87 88 89 90 | |
TokenError
¶
Bases: SeedrError
Raised for errors related to token serialization or deserialization.
Source code in seedrcc/exceptions.py
93 94 95 96 | |