diff --git a/changelog.d/fix-silent-exception-swallowing.fixed.md b/changelog.d/fix-silent-exception-swallowing.fixed.md new file mode 100644 index 00000000..4b10062e --- /dev/null +++ b/changelog.d/fix-silent-exception-swallowing.fixed.md @@ -0,0 +1 @@ +Log exceptions instead of silently swallowing them during household calculations. diff --git a/policyengine_api/country.py b/policyengine_api/country.py index befa4985..0cc7f380 100644 --- a/policyengine_api/country.py +++ b/policyengine_api/country.py @@ -1,4 +1,5 @@ import importlib +import logging from flask import Response import json from policyengine_core.taxbenefitsystems import TaxBenefitSystem @@ -445,11 +446,9 @@ def calculate( entity_result ) except Exception as e: - if "axes" in household: - pass - else: + logging.exception(f"Error computing {variable_name} for {entity_id}") + if "axes" not in household: household[entity_plural][entity_id][variable_name][period] = None - print(f"Error computing {variable_name} for {entity_id}: {e}") tracer_output = simulation.tracer.computation_log log_lines = tracer_output.lines(aggregate=False, max_depth=10)