manages exception handling code and default exceptions More...
#include <BESExceptionManager.h>
Public Member Functions | |
virtual void | add_ehm_callback (p_bes_ehm ehm) |
Register an exception handler with the manager. | |
virtual void | dump (ostream &strm) const |
dumps information about this object | |
virtual int | handle_exception (BESError &e, BESDataHandlerInterface &dhi) |
Manage any exceptions thrown during the handling of a request. | |
Static Public Member Functions | |
static BESExceptionManager * | TheEHM () |
Protected Member Functions | |
BESExceptionManager () | |
virtual | ~BESExceptionManager () |
manages exception handling code and default exceptions
The BESExceptionManager, a singleton, manages exceptions that are thrown during the handling of a request. Exceptions are handled by creating error informational objects and/or handling the exception and continuing.
If an error informational object is created then assign the new informational object to BESDataHandlerInterface.error_info variable.
No error information should be transmitted during the handling of the exception as we give the server code a chance to react to an exception before the exception information is sent.
The exception information is sent during the transmit of a response. An exception is handled just like any other response in terms of being transmitted.
Modules have a chance of registering exception handlers to the manager to be able to handle exceptions differently, or handle specific exceptions in a specific way. Exception handling functions are registered with the following signature:
int function_name( BESError &e, BESDataHandlerInterface &dhi ) ;
If the registered functioon does not handle the exception then the function should return BES_EXECUTED_OK0. If it does handle the exception, return a status code representative of the exception. Currently registered status returns can be found in BESError.h
If no handler can handle the exception then the default is to create a BESInfo object with the given exception.
Definition at line 84 of file BESExceptionManager.h.
BESExceptionManager::BESExceptionManager | ( | ) | [protected] |
Definition at line 43 of file BESExceptionManager.cc.
Referenced by TheEHM().
BESExceptionManager::~BESExceptionManager | ( | ) | [protected, virtual] |
Definition at line 47 of file BESExceptionManager.cc.
void BESExceptionManager::add_ehm_callback | ( | p_bes_ehm | ehm | ) | [virtual] |
Register an exception handler with the manager.
Signature of the function is as follows:
int function_name( BESError &e, BESDataHandlerInterface &dhi ) ;
If the handler does not handle the exception then it should return 0. Otherwise, return a status code. Pre-defined status codes can be found in BESError.h
ehm | exception handler function |
Definition at line 65 of file BESExceptionManager.cc.
Referenced by BESDapModule::initialize().
void BESExceptionManager::dump | ( | ostream & | strm | ) | const [virtual] |
dumps information about this object
Displays the pointer value of this instance along with the number of registered exception handler callbacks. Currently there is no way of telling what callbacks are registered, as no names are passed to the add method.
strm | C++ i/o stream to dump the information to |
Implements BESObj.
Definition at line 144 of file BESExceptionManager.cc.
References BESIndent::Indent(), BESIndent::LMarg(), and BESIndent::UnIndent().
int BESExceptionManager::handle_exception | ( | BESError & | e, | |
BESDataHandlerInterface & | dhi | |||
) | [virtual] |
Manage any exceptions thrown during the handling of a request.
An informational object should be created and assigned to BESDataHandlerInterface.error_info variable.
The manager first determines if a registered exception handler can handle the exception. First one to handle the exception wins. 0 is returned from the registered handler if it cannot handle the exception.
If no registered handlers can handle the exception then the default is to create an informational object (BESInfo instance) and the exception information stored there.
e | excption to be managed | |
dhi | information related to request and response |
Definition at line 91 of file BESExceptionManager.cc.
References BESDataHandlerInterface::action_name, BESInfo::add_exception(), BESInfo::begin_response(), BESInfoList::build_info(), DEFAULT_ADMINISTRATOR, BESInfo::end_response(), BESDataHandlerInterface::error_info, BESError::get_error_type(), BESKeys::get_value(), TheBESKeys::TheKeys(), and BESInfoList::TheList().
Referenced by BESInterface::exception_manager().
BESExceptionManager * BESExceptionManager::TheEHM | ( | ) | [static] |
Definition at line 154 of file BESExceptionManager.cc.
References BESExceptionManager().
Referenced by BESInterface::exception_manager(), and BESDapModule::initialize().