I add a lot of validations using if. If I can't use if, for example using a function that may throw error, I will add try catch only if I want to do something when an exception is thrown. If there is nothing to do when an exception is thrown, I will let the exception bubble up. I have application level exception handling to log the error.
I avoid using try catch to control program flow because it is not easy to spot that a codeblock will emit an exception: you have to read the whole codeblock to find places that emit exception.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I add a lot of validations using
if
. If I can't useif
, for example using a function that may throw error, I will addtry catch
only if I want to do something when an exception is thrown. If there is nothing to do when an exception is thrown, I will let the exception bubble up. I have application level exception handling to log the error.I avoid using
try catch
to control program flow because it is not easy to spot that a codeblock will emit an exception: you have to read the whole codeblock to find places that emit exception.