DEV Community

Discussion on: Let's Clean Up: Ugly Try-Catches!

Collapse
 
metruzanca profile image
Samuele Zanca

Isn't that cleaner!?

Imho, no. That's adding a useless dependency to a problem that's easily solved by adding return statement in the catch block. Could probably benefit from using more functional programming to refactor that bit but that depends purely on what other stuff is going on before this block.

Collapse
 
coly010 profile image
Colum Ferry

Agreed. You can add the return to the catch to break execution in the method, but you're still left with what I feel is less readable code. I guess it comes down to a matter of preference! :)

Collapse
 
metruzanca profile image
Samuele Zanca

A lot of coding is down to preference. :)