You’ve reached the end of the course! Joan’s donation import can now follow the trustees’ all-or-nothing rule in JavaScript: report every bad row together and import nothing until the export is ready. You can also explain a missing export and pause the script when a report needs investigating.
The finished import keeps the Python script’s reports and exit codes, including the corrected export’s total of £1,430.00 from five donations. The missing-file cause uses each runtime’s own wording, so that line differs between Python and JavaScript.
You now have the tools to:
- Define a family of errors under
DonationError, withExportMissingErrorandBadRowErrorfor the import’s different failures. Set extra fields aftersuper()and name subclasses in the base constructor withthis.name = new.target.name. - Keep the original error when you wrap it in a clearer one. Pass
{ cause: err }, forward options through your constructors tosuper(), and readerr.causefor the report’s second line. - Collect bad rows and throw
new AggregateError(problems, message), with the errors first. Catch the group by its own class and read its children througherr.errors. - Pause and step through the import with
node inspect, Chrome DevTools, or VS Code. Inspect the row’s variables and use conditional breakpoints to stop only on the row you need.