Portable exceptions.
Files "GException.h" and "GException.cpp" define a portable exception scheme used through the DjVu Reference Library. This scheme can use native C++ exceptions or an exception emulation based on longjmp/setjmp. A particular model can be forced a compile time by defining option CPP_SUPPORTS_EXCEPTIONS or USE_EXCEPTION_EMULATION.This emulation code was motivated because many compilers did not properly support exceptions as mandated by the C++ standard documents. This emulation is now considered obsolete because (a) it is not able to call the proper destructors when an exception occurs, and (b) it is not thread safe. Although all modern C++ compiler handle exception decently, the exception handling intrinsics are not always thread safe. Therefore we urge programmers to only use exceptions to signal error conditions that force the library to discontinue execution.
There are four macros for handling exceptions. Macros G_TRY, G_CATCH and G_ENDCATCH are used to define an exception catching block. Exceptions can be thrown at all times using macro G_THROW(cause). An exception can be re-thrown from a catch block using macro G_RETHROW.
Example:
G_TRY { // program lines which may result in a call to THROW() G_THROW("message"); } G_CATCH(ex) { // Variable ex refers to a GException object. ex.perror(); // You can rethrow the exception to an outer exception handler. G_RETHROW; } G_ENDCATCH;
Alphabetic index Hierarchy of classes