DEV Community

Discussion on: The fight between Try-Catch and If-Else

Collapse
 
itachiuchiha profile image
Itachi Uchiha

Imho, try-catch blocks are designed for exceptional cases, on the other hand, if-else blocks are designed for program logic.

There is no control rule in the try-catch specification for example;

try(age != null)

And you can't catch unexpected exceptions in the if blocks.