Connecting from Connection Results

An exception is any user, logic, or system error detected by a function that does not deal with the error itself but passes the error on to a handling routine, called an exception handler. In VisualAge, you can catch exceptions by connecting exception events to either actions or member functions.

An exception event is a feature of a connection, not a part. It appears as exceptionOccurred on the connection's connection menu. Exception events are typically connected to IMessageBox* parts, which are used to display error messages associated with the exceptions.

The return type of a target action displays as the actionResult event of the connection. You can connect the actionResult event to a feature of the same part or another part.

To connect an exception event, do the following:

  1. Write a member function or action that throws an exception. The easiest way to do this is to include something like the following:
    throw IException("Error message.");
    

    where the text of the error message that you want to display in the message box is the only parameter given for the IException constructor.

  2. For an action, update the part interface.

  3. Connect an event to the action or member function you just created.

  4. Drop an IMessageBox* part on the free-form surface. This message box will display the error message in the completed application.

  5. Connect the exceptionOccurred event of the connection to the showException action of the IMessageBox* part.

    This connection causes the application to show a message box that contains the exception error message whenever the exception is thrown.


Related concepts
Connections

Related procedures
Connecting Features to Other Features
Connecting Features to Member Functions
Connecting Features to Custom Logic
Opening Connection Settings
Selecting and Deselecting Connections