From c9dc159cca5e0ed931a69b657d44122ebd3e7796 Mon Sep 17 00:00:00 2001
From: Christopher Rhodes <christopher.rhodes@embl.de>
Date: Thu, 19 Oct 2023 15:41:30 +0200
Subject: [PATCH] Override exception handling if specified

---
 extensions/chaeo/util.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/extensions/chaeo/util.py b/extensions/chaeo/util.py
index 60186ef5..a7131801 100644
--- a/extensions/chaeo/util.py
+++ b/extensions/chaeo/util.py
@@ -50,7 +50,7 @@ def get_matching_files(where: str, ext: str, coord_filter: dict={}) -> str:
 
 
 def loop_workflow(files, where_output, workflow_func, params,
-                  write_intermediate_products=True):
+                  write_intermediate_products=True, catch_and_continue=True):
     failures = []
     for ii, ff in enumerate(files):
         export_kwargs = {
@@ -63,12 +63,15 @@ def loop_workflow(files, where_output, workflow_func, params,
         try:
             result = workflow_func(**export_kwargs)
         except Exception as e:
-            failures.append({
-                'input_file': ff,
-                'error_message': e.__str__(),
-            })
-            print(f'Caught failure on {ff}:\n{e.__str__()}')
-            continue
+            if catch_and_continue:
+                failures.append({
+                    'input_file': ff,
+                    'error_message': e.__str__(),
+                })
+                print(f'Caught failure on {ff}:\n{e.__str__()}')
+                continue
+            else:
+                raise e
 
         # record dataframes associated with workflow results
         batch_csv = {
-- 
GitLab