appevents OnException event
Return to Introduction  Previous page  Next page
Applies to
acAppEvents, acThread and acSQLQueryThread components.  

  TExceptionEvent = procedure(Sender: TObject; E: Exception) of object;  
property OnException: TExceptionEvent;  

The OnException event occurs when an unhandled exception occurs in the application.  
Use OnException to change the default behavior that occurs during an unhandled exception in the application. The OnException event handler is called automatically in the HandleException method.  
OnException only handles exceptions that occur during message processing. Exceptions that occur before or after the execution of Application.Run do not generate OnException events.  
If an exception passes through the try blocks in the application code, the application automatically calls the HandleException method. Unless the exception object is EAbort, HandleException calls the OnException handler, if one exists, otherwise it calls ShowException to display a message dialog box indicating an error occurred.  
The TExceptionEvent type is the type of the OnException event. It points to a method that handles exceptions in the application. The Sender parameter is the object that raised the exception, and E is the exception object.