DEV Community

Discussion on: Code Smell 132 - Exception Try Too Broad

Collapse
 
xtofl profile image
xtofl

I agree to the idea, but the example violates the 'fail fast' principle.

It should not let you input a month when the year is already unparseable.

Indeed, the very try block contains too much code, which results in an awkward effort to reconstruct which of the three statements went wrong.

This could be greatly improved by try/except for each input separately.