You’ve finished the course and Joan’s port. node donations.js november.csv lists all three bad rows and imports nothing. A missing export explains itself in a “caused by” line, and the corrected export imports five donations for £1,430.00. Only that cause line differs from Python, since each runtime phrases its own file error message.
You now have the tools to:
- Define a family of errors on one base class that names them with
this.name = new.target.name, setting extra fields aftersuper() - Wrap an error in a clearer one with
{ cause: err }, forwarding options tosuper(), and read the chain througherr.cause - Collect many errors and throw them as one
new AggregateError(problems, message), then handle them througherr.errors - Pause and step through a script with
node inspect, Chrome DevTools or VS Code
Keep the Habits That Carry Over
Give the program one base class for its own failures. Pass the original error on whenever you throw a new one. Catch by class, most specific first. One catch (err) receives every error, so end the instanceof chain with else { throw err; }, where Python lets an unmatched exception propagate.