In certain cases, it is impossible or impractical to return a shrc. For example, REF(T)::operator-> does not have an opportunity to return an error code, because of the way C++ defines operator->. Ideally, errors from overloaded operators would raise an exception that could be caught and handled by the application. Unfortunately, C++ exceptions are not stable enough to be used. Therefore, in situations where it is impractical to return a shrc, Shore calls a handler function, passing a shrc as its argument. The default handler function simply prints the shrc and exits by calling _exit (this form of exit does not call global destructors).
Applications can install their own error handler by calling Shore::set_error_handler. This method takes a pointer to a handler function as its argument. It installs the given function as the new handler and returns the old handler function. Passing a zero argument to Shore::set_error_handler reinstalls the default handler.
By installing a handler function, an application gives itself an opportunity to clean up its transient state before aborting a transaction. Once the transient state has been cleaned up, the handler function can call SH_ABORT_TRANSACTION to abort the transaction and longjmp back to the call to SH_BEGIN_TRANSACTION. Alternately, the handler function can exit the process with _exit. A handler function should not return, however. If it does, then Shore will terminate the process by calling _exit.
The error-handling functions are documented in errors(OC) and rc(FC).