2021-11-01 16:42:52 -06:00
|
|
|
from http import HTTPStatus
|
|
|
|
|
|
2024-05-01 17:42:26 -06:00
|
|
|
from sanic import SanicException
|
2021-11-01 16:42:52 -06:00
|
|
|
|
2024-05-01 17:42:26 -06:00
|
|
|
|
|
|
|
|
class APIError(SanicException):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'APIError'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'No summary defined'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.INTERNAL_SERVER_ERROR
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnknownDirectory(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'UNKNOWN_DIRECTORY'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'The directory does not exist.'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.NOT_FOUND
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnknownFile(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'UNKNOWN_FILE'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'The file does not exist.'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.NOT_FOUND
|
2021-12-20 16:08:13 -07:00
|
|
|
|
|
|
|
|
|
2021-11-01 16:42:52 -06:00
|
|
|
class SearchEmpty(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'SEARCH_EMPTY'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Search is empty, search_str must have content.'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class ValidationError(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'VALIDATION_ERROR'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Could not validate the contents of the request'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidOrderBy(ValidationError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'INVALID_ORDER_BY'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Invalid order_by'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class WROLModeEnabled(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'WROL_MODE_ENABLED'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'This method is disabled while WROL Mode is enabled.'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.FORBIDDEN
|
2021-11-01 16:42:52 -06:00
|
|
|
|
|
|
|
|
|
2021-12-20 16:08:13 -07:00
|
|
|
class InvalidDownload(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'INVALID_DOWNLOAD'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'The URL cannot be downloaded.'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2021-12-20 16:08:13 -07:00
|
|
|
|
|
|
|
|
|
2024-07-20 15:35:16 -06:00
|
|
|
class UnknownDownload(APIError):
|
|
|
|
|
code = 'UNKNOWN_DOWNLOAD'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'The Download cannot be found.'
|
2024-07-20 15:35:16 -06:00
|
|
|
status_code = HTTPStatus.NOT_FOUND
|
|
|
|
|
|
|
|
|
|
|
2021-12-20 16:08:13 -07:00
|
|
|
class UnrecoverableDownloadError(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'UNRECOVERABLE_DOWNLOAD_ERROR'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Download experienced an error which cannot be recovered. Download will be deleted.'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2021-12-20 16:08:13 -07:00
|
|
|
|
|
|
|
|
|
2026-03-08 11:08:08 -06:00
|
|
|
class BotBlockedDownloadError(UnrecoverableDownloadError):
|
|
|
|
|
code = 'BOT_BLOCKED_DOWNLOAD_ERROR'
|
|
|
|
|
summary = 'Download was blocked by bot detection or invalid cookies. All pending downloads will be stopped.'
|
|
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
|
|
|
|
|
|
|
|
|
|
2022-01-29 16:50:22 -07:00
|
|
|
class InvalidFile(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'INVALID_FILE'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'File does not exist or is a directory'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2022-01-29 16:50:22 -07:00
|
|
|
|
|
|
|
|
|
2022-02-04 09:41:08 -07:00
|
|
|
class NativeOnly(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'NATIVE_ONLY'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'This functionality is only supported outside a docker container'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2022-02-04 09:41:08 -07:00
|
|
|
|
|
|
|
|
|
2022-02-16 21:57:27 -07:00
|
|
|
class HotspotError(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'HOTSPOT_ERROR'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Updating/accessing Hotspot encountered an error'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.INTERNAL_SERVER_ERROR
|
2022-02-16 21:57:27 -07:00
|
|
|
|
|
|
|
|
|
2023-09-08 17:10:15 -06:00
|
|
|
class LogLevelError(APIError):
|
|
|
|
|
code = 'LOG_LEVEL_ERROR'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Log level is invalid'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2023-09-08 17:10:15 -06:00
|
|
|
|
|
|
|
|
|
2022-08-06 05:22:07 +00:00
|
|
|
class UnknownArchive(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'UNKNOWN_ARCHIVE'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Unable to find the archive'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.NOT_FOUND
|
2022-08-06 05:22:07 +00:00
|
|
|
|
|
|
|
|
|
2023-03-24 08:58:18 -06:00
|
|
|
class UnknownTag(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'UNKNOWN_TAG'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Unable to find the tag'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.NOT_FOUND
|
2023-03-24 08:58:18 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class UsedTag(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'USED_TAG'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Tag is being used'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2023-03-24 08:58:18 -06:00
|
|
|
|
|
|
|
|
|
2023-03-27 16:17:33 -06:00
|
|
|
class InvalidTag(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'INVALID_TAG'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Tag is not allowed'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2023-03-27 16:17:33 -06:00
|
|
|
|
|
|
|
|
|
2023-04-12 11:42:13 -06:00
|
|
|
class FileGroupIsTagged(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'FILE_GROUP_IS_TAGGED'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'FileGroup is tagged'
|
2024-07-30 17:14:08 -06:00
|
|
|
status_code = HTTPStatus.CONFLICT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FileGroupAlreadyTagged(APIError):
|
|
|
|
|
code = 'FILE_GROUP_ALREADY_TAGGED'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'FileGroup is already tagged with this Tag'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.CONFLICT
|
2023-04-12 11:42:13 -06:00
|
|
|
|
|
|
|
|
|
2023-04-18 22:03:45 -06:00
|
|
|
class FileUploadFailed(APIError):
|
2023-07-17 14:21:27 -06:00
|
|
|
code = 'FILE_UPLOAD_FAILED'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Failed to upload file'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2023-04-18 22:03:45 -06:00
|
|
|
|
2023-05-29 18:04:03 -06:00
|
|
|
|
2023-07-17 14:21:27 -06:00
|
|
|
class FileConflict(APIError):
|
|
|
|
|
code = 'FILE_CONFLICT'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'File/directory already exists'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.CONFLICT
|
2023-05-29 18:04:03 -06:00
|
|
|
|
|
|
|
|
|
2023-07-17 14:21:27 -06:00
|
|
|
class HotspotPasswordTooShort(APIError):
|
|
|
|
|
code = 'HOTSPOT_PASSWORD_TOO_SHORT'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Hotspot password must be at least 8 characters'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2023-08-17 20:07:02 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class ShutdownFailed(APIError):
|
|
|
|
|
code = 'SHUTDOWN_FAILED'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Unable to shutdown the WROLPi'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.INTERNAL_SERVER_ERROR
|
2023-09-08 17:10:15 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidConfig(APIError):
|
|
|
|
|
code = 'INVALID_CONFIG'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Config is invalid'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2023-09-15 12:03:09 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class NoPrimaryFile(APIError):
|
|
|
|
|
code = 'NO_PRIMARY_FILE'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Could not find a primary file in the provided group'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.INTERNAL_SERVER_ERROR
|
2023-10-29 22:15:57 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidDatetime(APIError):
|
|
|
|
|
code = 'INVALID_DATETIME'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Unable to parse a datetime string'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.INTERNAL_SERVER_ERROR
|
2024-02-19 13:45:41 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidDirectory(APIError):
|
|
|
|
|
code = 'INVALID_DIRECTORY'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Directory is not valid or impossible'
|
2024-05-01 17:42:26 -06:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
2024-08-07 08:36:33 -06:00
|
|
|
|
|
|
|
|
|
2026-01-09 14:01:25 -07:00
|
|
|
class FileWorkerConflict(APIError):
|
|
|
|
|
code = 'FILE_WORKER_CONFLICT'
|
|
|
|
|
summary = 'Not possible while FileWorker is busy'
|
2024-08-07 08:36:33 -06:00
|
|
|
status_code = HTTPStatus.CONFLICT
|
2025-01-10 11:33:21 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class IgnoredDirectoryError(APIError):
|
|
|
|
|
code = 'IGNORED_DIRECTORY_ERROR'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Directory is being ignored'
|
2025-01-10 11:33:21 -07:00
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DownloadError(APIError):
|
|
|
|
|
code = 'DOWNLOAD_ERROR'
|
2025-02-19 14:52:50 -07:00
|
|
|
summary = 'Unable to complete download'
|
2025-01-10 11:33:21 -07:00
|
|
|
status_code = HTTPStatus.INTERNAL_SERVER_ERROR
|
2025-10-29 22:16:33 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnknownCollection(APIError):
|
|
|
|
|
code = 'UNKNOWN_COLLECTION'
|
|
|
|
|
summary = 'Unable to find the collection'
|
|
|
|
|
status_code = HTTPStatus.NOT_FOUND
|
2026-03-15 12:58:40 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnsupportedArchive(APIError):
|
|
|
|
|
code = 'UNSUPPORTED_ARCHIVE'
|
|
|
|
|
summary = 'The file is not a supported archive format.'
|
|
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidArchiveMember(APIError):
|
|
|
|
|
code = 'INVALID_ARCHIVE_MEMBER'
|
|
|
|
|
summary = 'The requested member does not exist in the archive.'
|
|
|
|
|
status_code = HTTPStatus.BAD_REQUEST
|