TelegramPoster/classes/exceptions.py

23 lines
667 B
Python
Raw Normal View History

2023-02-17 17:45:51 +02:00
from typing import Any
class SubmissionUnavailableError(Exception):
pass
2023-03-09 12:33:02 +02:00
2023-02-17 17:45:51 +02:00
class SubmissionUploadError(Exception):
def __init__(self, file_path: str, status_code: int, content: Any) -> None:
self.status_code = status_code
self.content = content
2023-03-09 12:33:02 +02:00
super().__init__(
f"Could not upload photo '{file_path}' due to HTTP {self.status_code}: {self.content}"
)
2023-02-17 17:45:51 +02:00
class SubmissionDuplicatesError(Exception):
def __init__(self, file_path: str, duplicates: list) -> None:
self.duplicates = duplicates
2023-03-09 12:33:02 +02:00
super().__init__(
f"Found duplicates of a photo '{file_path}': {self.duplicates}"
)