[Lazarus] Exception dialog
Martin Friebe
lazarus at mfriebe.de
Tue Mar 17 13:02:16 CET 2009
Michael Van Canneyt wrote:
> On Mon, 16 Mar 2009, Hans-Peter Diettrich wrote:
>
>
>> Michael Van Canneyt schrieb:
>>
>>
>>> Is there a reason why the default exception dialog has a cancel
>>> button to kill the application ?
>>>
>> An unhandled exception IMO is due to some software bug, which the user
>> cannot cure in any way.
>>
>
> That's a very restrictive definition of exception. An exception is
> a way to stop the normal logic and flow of the program. In a GUI
> application, you rely on the program's event loop to catch the
> exception (so it is definitely handled) and to show it to the
> user. If you don't want it to be shown, use the Abort exception.
>
there is a different between an "unhandled exception" and an "exception"
An exception is indeed a very valid thing, that can and maybe should
occur within many applications. But any exception should have some code,
that handles it.
And this handling code should not be the build-in Lazarus-exception
dialog. Because the build-in dialog does not know what the exception
meant and what should be done. It could not clean-up, it could not make
sure that any memory allocated and referred only by local variables is
freed.
So an *unhanded* exception is a software bugs. an unhandled exception in
most languages will simply crash the application. The fact that a
Lazarus app does ask the user, if he wants to try and continue (and
maybe be able to save his work) is a benefit.
But never the less ending up there is a bug. The user doesn't know if he
hit an exception for which the programmer intended to fall back on the
build-in dialog (and therefore that the app will still run stable); or
if this was an exception the programmer did not foresee, and the app
will no be unstable, more exceptions may happen, data be corrupted.....
"In a GUI application, you rely on the program's event loop" ....
Well, in my very personal opinion: This is just a bad design idea. If I
throw an exception, I write a handler for it.
Best regards
Martin
More information about the Lazarus
mailing list