You’ve finished When Things Go Wrong: Errors and Debugging. First, the season log crashed, and you read the report from the top: formatRun() threw a TypeError. The next line down led to printSeason(), whose loop ran one pass too far. The fix went there, on the bug line.
Next, checkRun() threw errors that name the run. Each one climbed out to the catch in the import loop, which reported the bad run and skipped it. Last, Priya’s total came out ten kilometers short, with no error. Your debugging card held the expected and actual totals, and a hypothesis a check could prove wrong. Halving the runs left run 7, whose runner name ends in a space.
In This Course, You Learned How To
- Read a stack trace to find where a failure starts
- Catch only the errors your code can handle
- Throw errors with useful messages, and catch them at the right level
- Track down a wrong result with a method instead of guessing
- Build Ruth’s season log, and explain how it works