views:

163

answers:

4

When running a Delphi application outside the debugger most exceptions that occur seem to be silently ignored (like an access violation). Sometimes however there appears the Windows error reporting dialog (send or not send, you probably know what I mean). What exactly does this mean? What errors trigger this behaviour?

Additional info: I have a global exception handler for my application that should log all unhandled exceptions. So, no exceptions should leave the application unhandled.

Thanks.

+2  A: 

It covers exceptions that are not handled by the application - if an exception propagates outside of the main entry point of the app, then WER will step in. This covers things like AVs, divide by zero, invalid handle access and other out of band or "chip" exceptions. Sometimes your code can attempt to handle those things, but if memory is corrupted too badly or what have you, then your code will die.

1800 INFORMATION
+1  A: 

Exceptions occurring in initialization and finalization sections would escape your global exception handler and trigger WER.

Lars Truijens
+2  A: 

Most exceptions are not silently ignored when running outside the debugger. They are normally caught by the event loop in VCL applications, or fall through to the main begin/end in console applications, etc. The default aciton of the VCL event loop is to display a dialog containing the message associated with the exception.

It's if the exception escapes the application, either by reaching the main begin/end without being caught, or not being caught by the event loop, that the Windows error reporting steps in - functionally, it is an exception handler just like any other except at the very base of the stack.

Barry Kelly
Thanks! Note that I have a global exception handler that should catch unhandled exceptions (that was what I meant by "silently ignored"). Anyway, sometimes the windows error reporting steps in and I wonder why...
Smasher
Because the unhandled exception occurs either before your global handler is put in place during application startup, or after the global handler is disconnected during shutdown of your application.
Ken White
@Ken: No, definitely not. It happens while the application is running (ony after a couple of minutes). And the application only closes after closing the error reporting dialog.
Smasher
+2  A: 

You will generally get problems if you have exceptions in threads that are not handled in the Execute method. The program will mostly be killed, but the behaviour is unpredictable and seems to depend on many things (like the number and state of other threads). Often the main window vanishes immediately, and any further exceptions will thus not be handled by the program, and this is probably what causes WER to catch them.

I made it a habit to have an outer exception handler in Execute that logs any unhandled exceptions and allows the thread to terminate cleanly.

mghie