🥅 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
+7 -3
View File
@@ -7,7 +7,7 @@ from loguru import logger
from scripts.status_check import headers
from src.downloader.download import Downloader
from src.exceptions import AppNotFound
from src.exceptions import UptoDownAPKDownloadFailure
from src.utils import bs4_parser
@@ -20,7 +20,9 @@ class UptoDown(Downloader):
soup = soup.find(id="detail-download-button")
download_url = soup.get("data-url")
if not download_url:
raise AppNotFound("Unable to download from uptodown.")
raise UptoDownAPKDownloadFailure(
f"Unable to download {app} from uptodown.", url=page
)
self._download(download_url, f"{app}.apk")
logger.debug(f"Downloaded {app} apk from upto_down_downloader in rt")
@@ -45,7 +47,9 @@ class UptoDown(Downloader):
download_url = version_item["data-url"]
break
if download_url is None:
raise AppNotFound(f"Unable to get download url for {app}")
raise UptoDownAPKDownloadFailure(
f"Unable to download {app} from uptodown.", url=url
)
self.extract_download_link(download_url, app)
logger.debug(f"Downloaded {app} apk from upto_down_downloader in rt")