So let’s say I build a class with methods that may result in a fatal exception, such as network failure. Is it best practice to:
1) Throw an exception and let the calling procedure trap and handle it?
2) Raise a class event for which the calling procedure has added a handler?
3) Suppress the exception and return False or Nothing from the method rather than the intended result?
My apologies if this is an irritatingly trivial question. I’m new to .NET
I would rather go with option 1.
Provide as much information in the exception as possible, and let the caller handle the exception.
Further to this, you should also try to rethrow the exception (or not catch it in the first place) so that the caller might receive the original message and stack trace.
You should almost never swallow an exception without the caller knowing of it.
From Exceptions and Exception Handling (C# Programming Guide)