How does eCAP deal with C++ exceptions?

Created by Alex Rousskov
Keywords:

The host application may throw exceptions (when the adapter calls a host application function or method). Thus, adapters should be written using exception-safe code.

* If an eCAP adapter wants the host application to handle the exception, then that adapter should do nothing special. The adapter does not need any special try/catch blocks -- all exceptions will bubble "through" the adapter code up to the host application.

* If an eCAP adapter wants to handle an exception, then it certainly can wrap relevant calls with try/catch blocks. In this case, the host application will not know anything about the exception. This approach is not recommended for exceptions thrown by the host application.

Various combinations of the above basic two cases are possible inside one adapter, of course.

Ideally, the host application should handle any adapter exception without exiting: Transaction exceptions should be treated as transaction adaptation failures. Service exceptions should be treated as service failures. The host application should report details of exceptions derived from std::exception.

If a buggy host application mishandles exceptions, then you can probably bypass the problem using try/catch blocks in your adapter code (where the throwing calls are made). Do not forget to report the bug to your host application support team!