Skip to content

Commit 68a550f

Browse files
committed
Improves error handling with descriptive error messages as warnings.
1 parent 72c74d7 commit 68a550f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/multi_component_hydrogen_bond_propensity/multi_component_hydrogen_bond_propensity_report.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,12 @@ def main(structure, work_directory, failure_directory, library, csdrefcode):
358358
tdata = get_mc_scores(propensities, crystal.identifier)
359359
json.dump(tdata, file)
360360
mc_dictionary[coformer_name] = get_mc_scores(propensities, crystal.identifier)
361-
except RuntimeError:
361+
except RuntimeError as error_message:
362362
print("Propensity calculation failure for %s!" % coformer_name)
363+
error_string = f"{coformer_name}: {error_message}"
364+
warnings.warn(error_string)
363365
mc_dictionary[coformer_name] = ["N/A", "N/A", "N/A", "N/A", "N/A", crystal.identifier]
364-
failures.append(coformer_name)
366+
failures.append(error_string)
365367

366368
# Make sense of the outputs of all the calculations
367369
mc_hbp_screen = sorted(mc_dictionary.items(), key=lambda e: 0 if e[1][0] == 'N/A' else e[1][0], reverse=True)

0 commit comments

Comments
 (0)