Reporting Every Bad Row With AggregateError
At the start of the course, Python listed November’s bad rows, and the JavaScript port crashed with
an AggregateError: 3 bad rows in november.csv. The trustees’ rule is all or nothing, every bad
row in one report.
In Python, import_month() collects each BadRowError in problems and raises an
ExceptionGroup, a message and then the errors:
if problems:
message = f"{len(problems)} bad rows in {path}"
raise ExceptionGroup(message, problems)
JavaScript’s group is AggregateError, a built-in Error with an array named errors, where
Python’s has exceptions. The raise ports as a throw of a new AggregateError: