OnException (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example requires that a TApplicationEvents and a TListBox are on the form. Select the TApplicationEvents, double-click the OnException event, and add the following code to the handler. Trigger this event by calling the Exception Create constructor.

Code

void __fastcall TAppEventForm::ApplicationEventsException(TObject *Sender,
      Exception *E)
{
    lbOther->Items->Add("Event OnException: " + E->Message);
}

void __fastcall TAppEventForm::MenuExceptionClick(TObject *Sender)
{
	char *sExceptionRaised = "This is an exception";
	throw Exception(sExceptionRaised);
}

Uses