Problem:
This example program demonstrates the use of Exception Handling when working within an OLE environment.
Resolution:
INTRODUCTION
==========
This example program demonstrates the use of Exception Handling when working within an OLE environment. This program contains two entry points. The first entry point is the default Procedure Division for TestException. This is where execution begins. The second entry point is named "MyHandler" and it contains the Exception Handling code which will be called whenever an OLE Exception occurs during the processing of TestException. Two parameters are automatically passed to "MyHandler" by the OLE Exception Handler within the Net Express run-time system. The parameters are defined in the Linkage Section and they are defined as:
01 lnkExceptionObject object reference.
01 lnkExceptionNumber pic x(4) comp-5.
lnkExceptionObject contains the object for the OLEExceptionManager, and lnkExceptionNumber is an exception ID number which can be used to calculate an offset into the OLE eror table as defined within this program.
The first task that is done by the "TestException" program is to create an EntryCallback object for the entry point "MyHandler" and register this as an Exception Handler with the OLEExceptionManager class. We could have also created a Callback specifying a method name to register instead of the entry point.
After the Exception Handler is registered then any OLE error that occurs during program execution will cause the specified handler code to be called or invoked using the two parameters already discussed.
The class designation for the Microsoft Word automation server was intentionally modified in this example so that an exception would be triggered as soon as the program tried to create an instance of the class by invoking the "new" method on it.
REQUIREMENTS:
==========
This program can be run under any Net Express 3.1 or higher development environment.
OPERATION:
========
Run this program under control of the Animator in order to watch the exception handling code being called when the error occurs.
NOTE:
====
For more information on developing applications using OLE see the Net Express Distributed Computing bookl in the Bookshelf for V3.1 and in the on-line Help for version 4.0.
==========================================================
Keywords: demonstration, sample, example, demo, testoleexception.zip
demo.ex
demo.ne