Or any other design that has the gui widgets as being the first port of call where an unhandled exception will kill the app?
We all want one main: ‘catch all’ for face saving purposes (although in most cases this shouldn’t have a ‘continue’ feature) but it is impossible to easily implement one with gui widgets that are the first port of call. Is this design flawed or am I missing a trick somewhere?
I ask this because I was reading an article by the designer of the language and he stated that Exception handling should be centralised and the first thing that popped into my head was the WinForm event mechanism where this becomes difficult.
Were the WinForm/GUI team listening to him, or was it possibly too late by then?
You can put a try/catch around Application.Run, and handle Application.ThreadException. In the handlers you can log the exception and exit.
Apart from the above, I usually put an exception handler around all calls to the Business Tier (and all access to external resources in the client tier, e.g. export to a file) which display an error but don’t exit the application.