🥅 Exception handling (#290)

This commit is contained in:
Nikhil Badyal
2023-08-17 21:09:42 +05:30
committed by GitHub
parent 5bffa4c79c
commit 02e550585c
11 changed files with 105 additions and 35 deletions
+63 -3
View File
@@ -16,6 +16,57 @@ class APKMirrorIconScrapFailure(Exception):
self.url = kwargs.get("url", None)
class DownloadFailure(Exception):
"""Generic Download failure."""
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Initialize the APKMirrorAPKDownloadFailure exception.
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
url (str, optional): The URL of the failed icon scraping. Defaults to None.
"""
super().__init__(*args)
self.url = kwargs.get("url", None)
class APKDownloadFailure(DownloadFailure):
"""Exception raised when the apk cannot be scraped."""
pass
class APKMirrorAPKDownloadFailure(APKDownloadFailure):
"""Exception raised when downloading an APK from apkmirror failed."""
pass
class APKMirrorAPKNotFound(APKDownloadFailure):
"""Exception raised when apk doesn't exist on APKMirror."""
pass
class UptoDownAPKDownloadFailure(APKDownloadFailure):
"""Exception raised when downloading an APK from uptodown failed."""
pass
class APKPureAPKDownloadFailure(APKDownloadFailure):
"""Exception raised when downloading an APK from apkpure failed."""
pass
class APKSosAPKDownloadFailure(APKDownloadFailure):
"""Exception raised when downloading an APK from apksos failed."""
pass
class PatchingFailed(Exception):
"""Patching Failed."""
@@ -28,7 +79,16 @@ class AppNotFound(ValueError):
pass
class PatchesJsonFailed(ValueError):
"""Patches failed."""
class PatchesJsonLoadFailed(ValueError):
"""Failed to load patches json."""
pass
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Initialize the PatchesJsonLoadFailed exception.
Args:
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
file_name (str, optional): The name of json file. Defaults to None.
"""
super().__init__(*args)
self.file_name = kwargs.get("file_name", None)