From 34008046b24366a45db3c9d10bab464635998a48 Mon Sep 17 00:00:00 2001 From: James Jennett-Wheeler Date: Wed, 25 Jun 2025 15:01:28 +0100 Subject: [PATCH] Log error before retry --- app/monitor-planning.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/monitor-planning.py b/app/monitor-planning.py index eee14ed..3341e45 100644 --- a/app/monitor-planning.py +++ b/app/monitor-planning.py @@ -46,8 +46,10 @@ def update_other_applications(): min(search_past_week + search_num_weeks, 9)): # Council only allow latest 9 weeks try: weekly_list.scrape(_browser, search_week_idx) - except Exception: - # try one more time + except Exception as e: + print(f'Error found: {repr(e)}') + print(traceback.format_exc()) + print("Try again") weekly_list.scrape(_browser, search_week_idx) there_were_newly_decided_applications = len(weekly_list.new_applications) > 0 @@ -66,8 +68,10 @@ def update_other_applications(): _app = Application(_cursor, application_ref) try: _app.scrape_portal(_browser) - except Exception: - # try one more time + except Exception as e: + print(f'Error found: {repr(e)}') + print(traceback.format_exc()) + print("Try again") _app.scrape_portal(_browser) if _app.caseOfficer == "Christopher Masters": @@ -95,8 +99,10 @@ if __name__ == '__main__': with webdriver.Chrome(options=web_opts) as browser: try: application.scrape_portal(browser, force=True, count_documents=True) - except Exception: - # try one more time + except Exception as e: + print(f'Error found: {repr(e)}') + print(traceback.format_exc()) + print("Try again") application.scrape_portal(browser, force=True, count_documents=True) if application.new_documents_found: