Conditional Checking:
if denominator == 0:
// do something like informng the user. or skipping this iteration.
else:
result = numerator/denominator
if FileExists('path/to/file'):
// open file read & write.
else:
// do something like informng the user. or skipping this iteration.
Exception Handling:
try:
result = numerator/denominator
catch (DevidedByZeroException):
//take action
try:
//open file read & write.
catch (FileNotExistsException):
//take action
I'm frequently encountering situations like this. Which one to go for? Why?