Profitroll
5adb004a2a
* `/report` command added * Updated to libbot 1.5 * Moved to [PhotosAPI_Client](https://git.end-play.xyz/profitroll/PhotosAPI_Client) v0.5.0 from using self-made API client * Video support (almost stable) * Bug fixes and improvements Co-authored-by: profitroll <vozhd.kk@gmail.com> Reviewed-on: #27
64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
from typing import Any
|
|
|
|
|
|
class SubmissionUnavailableError(Exception):
|
|
pass
|
|
|
|
|
|
class SubmissionUploadError(Exception):
|
|
def __init__(self, file_path: str, status_code: int, content: Any) -> None:
|
|
self.status_code = status_code
|
|
self.content = content
|
|
super().__init__(
|
|
f"Could not upload photo '{file_path}' due to HTTP {self.status_code}: {self.content}"
|
|
)
|
|
|
|
|
|
class SubmissionDuplicatesError(Exception):
|
|
def __init__(self, file_path: str, duplicates: list) -> None:
|
|
self.duplicates = duplicates
|
|
super().__init__(
|
|
f"Found duplicates of a photo '{file_path}': {self.duplicates}"
|
|
)
|
|
|
|
|
|
class SubmissionUnsupportedError(Exception):
|
|
def __init__(self, file_path: str) -> None:
|
|
super().__init__(f"Type of file does not seem to be supported: '{file_path}'")
|
|
|
|
|
|
class UserCreationError(Exception):
|
|
def __init__(self, code: int, data: str) -> None:
|
|
self.code = code
|
|
self.data = data
|
|
super().__init__(
|
|
f"Could not create a new user. API returned HTTP {self.code} with content: {self.data}"
|
|
)
|
|
|
|
|
|
class UserCreationDuplicateError(Exception):
|
|
def __init__(self, username: str) -> None:
|
|
self.username = username
|
|
super().__init__(f"User '{self.username} already exists.'")
|
|
|
|
|
|
class AlbumCreationError(Exception):
|
|
def __init__(self, code: int, data: str) -> None:
|
|
self.code = code
|
|
self.data = data
|
|
super().__init__(
|
|
f"Could not create a new album. API returned HTTP {self.code} with content: {self.data}"
|
|
)
|
|
|
|
|
|
class AlbumCreationDuplicateError(Exception):
|
|
def __init__(self, name: str) -> None:
|
|
self.name = name
|
|
super().__init__(f"Album '{self.name} already exists.'")
|
|
|
|
|
|
class AlbumCreationNameError(Exception):
|
|
def __init__(self, data: dict) -> None:
|
|
self.data = data
|
|
super().__init__(data["detail"])
|