In Java, calls to functions that can throw Exceptions need to anticipate them with either a try-catch or by adding a throws Exception to their function signature.
My main use for them is in my top-calling code, where I only put try-catches in sections that explicitly throw Exceptions.
However, because C# does not have checked exceptions, the only way I can think of anticipating Exceptions is to surround all sections of my top-calling code with try-catches. I personally do not like this approach for the following reasons:
It can lead to very messy code, putting
try-catches where they are not needed.I might miss a section that needs a
try-catch.
How do I properly anticipate Exceptions in my top-calling code in C#?