PAL: Process exception while writing table
[csit.git] / resources / tools / presentation / generator_tables.py
index a7b1500..59250d0 100644 (file)
@@ -489,10 +489,17 @@ def table_merged_details(table, input_data):
             separator = u"" if table[u'output-file'].endswith(u"/") else u"_"
             file_name = f"{table[u'output-file']}{separator}{suite_name}.csv"
             logging.info(f"      Writing file: {file_name}")
             separator = u"" if table[u'output-file'].endswith(u"/") else u"_"
             file_name = f"{table[u'output-file']}{separator}{suite_name}.csv"
             logging.info(f"      Writing file: {file_name}")
-            with open(file_name, u"wt") as file_handler:
-                file_handler.write(u",".join(header) + u"\n")
-                for item in table_lst:
-                    file_handler.write(u",".join(item) + u"\n")
+            try:
+                with open(file_name, u"wt") as file_handler:
+                    file_handler.write(u",".join(header) + u"\n")
+                    for item in table_lst:
+                        file_handler.write(u",".join(item) + u"\n")
+            except Exception as err:
+                logging.error(f"{err}")
+                logging.info(header)
+                logging.info(table_lst)
+                if file_handler:
+                    file_handler.close()
 
     logging.info(u"  Done.")
 
 
     logging.info(u"  Done.")