From 5b8a58ab37d5187dcf750b498d5e91b91f0c758a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 6 Dec 2021 15:51:29 -0800 Subject: SIM pipeline: improve exception handling --- fatcat_scholar/sim_pipeline.py | 11 +++++++---- fatcat_scholar/work_pipeline.py | 12 +++++------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'fatcat_scholar') diff --git a/fatcat_scholar/sim_pipeline.py b/fatcat_scholar/sim_pipeline.py index e140816..34aaae3 100644 --- a/fatcat_scholar/sim_pipeline.py +++ b/fatcat_scholar/sim_pipeline.py @@ -213,10 +213,13 @@ class SimPipeline: """ try: full_issue = self.fetch_sim_issue(issue_item, pub_collection) - except requests.exceptions.ConnectionError as e: - print(str(e), file=sys.stderr) - return - except requests.exceptions.ReadTimeout as e: + except ( + requests.exceptions.ConnectionError, + requests.exceptions.Timeout, + requests.exceptions.RetryError, + requests.exceptions.ChunkedEncodingError, + urllib3.exceptions.MaxRetryError, + ) as e: print(str(e), file=sys.stderr) return except requests.exceptions.ChunkedEncodingError as e: diff --git a/fatcat_scholar/work_pipeline.py b/fatcat_scholar/work_pipeline.py index 5c32767..f17d69d 100644 --- a/fatcat_scholar/work_pipeline.py +++ b/fatcat_scholar/work_pipeline.py @@ -412,13 +412,11 @@ class WorkPipeline: sim_fulltext = self.fetch_sim( sim_issue, sim_pub, release.pages, release.ident ) - except requests.exceptions.ConnectionError as e: - print(str(e), file=sys.stderr) - continue - except requests.exceptions.ReadTimeout as e: - print(str(e), file=sys.stderr) - continue - except requests.exceptions.ChunkedEncodingError as e: + except ( + requests.exceptions.ConnectionError, + requests.exceptions.ReadTimeout, + requests.exceptions.ChunkedEncodingError, + ) as e: print(str(e), file=sys.stderr) continue if sim_fulltext: -- cgit v1.2.3