-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
This module contains custom exceptions for the ytnoti package. | ||
""" | ||
|
||
from http import HTTPStatus | ||
|
||
|
||
class HTTPError(Exception): | ||
""" | ||
Exception raised when an HTTP error occurs. | ||
""" | ||
|
||
def __init__(self, message: str, status_code: int | HTTPStatus): | ||
""" | ||
Initialize the HTTPError object. | ||
:param message: The error message | ||
:param status_code: The status code of the error | ||
""" | ||
self.status_code = status_code if isinstance(status_code, HTTPStatus) else HTTPStatus(status_code) | ||
self.message = message | ||
|
||
def __str__(self): | ||
return f"Status code: {self.status_code}: {self.message}" |