Reference for hub_sdk/helpers/error_handler.py
Note
This file is available at https://github.com/ultralytics/hub-sdk/blob/main/hub_sdk/helpers/error_handler.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
hub_sdk.helpers.error_handler.ErrorHandler
Represents an error handler for managing HTTP status codes and error messages.
Attributes:
Name | Type | Description |
---|---|---|
status_code |
int
|
The HTTP status code associated with the error. |
message |
(str, None)
|
An optional error message providing additional details. Defaults to None. |
headers |
(dict, None)
|
An optional dictionary providing response headers details. Defaults to None. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status_code
|
int
|
The HTTP status code representing the error. |
required |
message
|
str
|
An optional error message providing additional details. |
None
|
headers
|
(dict, None)
|
An optional dictionary providing response headers details. |
None
|
Source code in hub_sdk/helpers/error_handler.py
get_default_message
Get the default error message for a given HTTP status code.
Returns:
Type | Description |
---|---|
str
|
The default error message associated with the provided status code. If no message is found, it falls back to handling an unknown error. |
Source code in hub_sdk/helpers/error_handler.py
handle
Handle the error based on the provided status code.
Returns:
Type | Description |
---|---|
str
|
A message describing the error. |
Source code in hub_sdk/helpers/error_handler.py
handle_internal_server_error
staticmethod
Handle an internal server error (HTTP 500).
Returns:
Type | Description |
---|---|
str
|
An error message indicating an internal server error. |
handle_not_found
staticmethod
Handle a resource not found error (HTTP 404).
Returns:
Type | Description |
---|---|
str
|
An error message indicating that the requested resource was not found. |
handle_ratelimit_exceeded
Handle rate limit exceeded error (HTTP 429).
Returns:
Type | Description |
---|---|
str
|
An error message indicating rate limit exceeded. |
Source code in hub_sdk/helpers/error_handler.py
handle_unauthorized
staticmethod
Handle an unauthorized error (HTTP 401).
Returns:
Type | Description |
---|---|
str
|
An error message indicating unauthorized access. |
handle_unknown_error
staticmethod
Handle an unknown error.
Returns:
Type | Description |
---|---|
str
|
An error message indicating that an unknown error occurred. |