In Python, there is this useful exception handling code:
try:
# Code that could raise an exception
except Exception:
# Exception handling
else:
# Cod
C# does not have such a concept, so you are just left with three options,