aboutsummaryrefslogtreecommitdiff
path: root/src/wikiget/wikiget.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/wikiget/wikiget.py')
-rw-r--r--src/wikiget/wikiget.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/wikiget/wikiget.py b/src/wikiget/wikiget.py
index 68e0233..4446f96 100644
--- a/src/wikiget/wikiget.py
+++ b/src/wikiget/wikiget.py
@@ -20,6 +20,9 @@ import logging
import sys
from concurrent.futures import ThreadPoolExecutor
+from mwclient import APIError, InvalidResponse, LoginError
+from requests import ConnectionError, HTTPError
+
import wikiget
from wikiget.dl import download, prep_download
from wikiget.exceptions import ParseError
@@ -178,6 +181,10 @@ def batch_download(args):
file = prep_download(line, args)
except ParseError as e:
logging.warning(f"{e} (line {line_num})")
+ except (ConnectionError, HTTPError, InvalidResponse, LoginError, APIError):
+ logging.error(
+ f"Unable to download '{line}' (line {line_num}) due to an error"
+ )
future = executor.submit(download, file, args)
futures.append(future)
# wait for downloads to finish
@@ -198,6 +205,8 @@ def main():
if args.batch:
# batch download mode
+ # TODO: return non-zero exit code if any errors were encountered, even if some
+ # downloads completed successfully
batch_download(args)
else:
# single download mode
@@ -206,4 +215,6 @@ def main():
except ParseError as e:
logging.error(e)
sys.exit(1)
+ except (ConnectionError, HTTPError, InvalidResponse, LoginError, APIError):
+ sys.exit(1)
download(file, args)