Loading lesson…
Level 1 · Apprentice0 XP
Failing clearly, cleaning up always, and never swallowing an error.
Step 1 / 5
ProblemA file is not found. The empty catch block hides it. The program carries on with no data and fails twenty lines later with a confusing NullPointerException. The real cause was thrown away.
← → step
Before this: Generics
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Write readPort(Path configFile) that reads a number from a file. Handle three failures with clear messages that include the path: the file is missing, the content is not a number, the number is outside 1 to 65535. Keep the original exception as the cause.