Stephan van Hulst wrote:It makes it explicit that the function might not have an answer. It forces the client to check that a result is present, because the first code snippet will cause a NullPointerException if the client forgets to check the result.
Junilu Lacar wrote:What "default handler" are you referring to? Java doesn't have a "default handler" as far as I know.
EDIT: Just noticed that this is in the C#/.Net forum -- I don't know if what I said is true for C#, honestly, but I'd imagine it is. (I could be wrong, of course)
Stephan van Hulst wrote:It's likely that the exception was caught in a higher call frame, but the catch clause was empty. If so, let it be a lesson: NEVER write empty catch clauses.
Stephan van Hulst wrote:
The second scenario doesn't happen that often. It's usually a sign that the method with the extra parameter does too much and should be split in smaller methods.