John Baird
Coatesville, Pennsylvania, United States
>What is a good way to do exception handling? I read in a book that everything excluding simple variable declarations should be in a Try Catch block. This make sense to me on the GUI side, but how about in the other tiers? Should I be including all code in my business classes and Data classes in Try Catch blocks? I tried this and it seems like it is overkill, as I usually end up just rethrowing the exception (sometimes multiple times) and letting the GUI handle it.
>
>What does everybody else do?
IMHO, you should wrap anything in your business classes and data classes in TryCatch blocks that require any outside input (like SQL, directories, imports, exports, xml, etc.). These exceptions are caught and rethrown to the parent calling method in the UI which should handle them or pass them further up the chain.
I just had a conversation with a gentlemen and one of our local user's groups and he was under the opinion that all errors should be handled without rethrowing them higher in the UI. I think they should be handled where it makes sense.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only