Skip to content

Commit

Permalink
Add a raise exception for failing download
Browse files Browse the repository at this point in the history
  • Loading branch information
meteoDaniel authored and meteoDaniel committed Jun 19, 2020
1 parent 6425275 commit 833b7f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python_dwd/download/download.py
Expand Up @@ -12,6 +12,7 @@
from python_dwd.download.download_services import create_remote_file_name
from python_dwd.additionals.functions import find_all_matchstrings_in_string
from python_dwd.enumerations.column_names_enumeration import DWDMetaColumns
from python_dwd.exceptions.failed_download_exception import FailedDownload


def download_dwd_data(remote_files: pd.DataFrame,
Expand Down Expand Up @@ -55,7 +56,7 @@ def _download_dwd_data(remote_file: Union[str, Path]) -> BytesIO:
except urllib.error.URLError as e:
raise e(f"Error: the stationdata {file_server} couldn't be reached.")
except:
print(file_server)
raise FailedDownload(f"Download failed for {file_server}")

try:
with zipfile.ZipFile(zip_file) as zip_file_opened:
Expand Down
6 changes: 6 additions & 0 deletions python_dwd/exceptions/failed_download_exception.py
@@ -0,0 +1,6 @@
""" Exception that can be thrown if download fails"""


class FailedDownload(Exception):
""" Failed download exception """
pass

0 comments on commit 833b7f8

Please sign in to comment.