Library error handling is supported by the use of exceptions.
This means that whenever a method cannot return the requested value because of inconsistencies within the parameters given or the data analysed, an exception will be raised instead. This exception can be caught at an upper level and program flow can take an alternative action in order to workaround the problem that raised the exception. Actually, all exceptions should be caught by the application in order to prevent it from abrupt termination.
In order to ease exception handling, all jaula exceptions are derived from JAULA::Exception base class. So, all jaula generated exceptions can be grouped in a single catch block as shown below:
try { // application code invoking jaula methods goes here } catch(JAULA::Exception const &jaulex) { // code dealing with jaula exceptions goes here std::cerr << "jaula exception detected : " << jaulex << std::endl; } catch(/* some other exceptions that may appear */) { // code dealing with other exception types }
As you may see in the pseudo code fragment above, all JAULA::Exception instances share an insertion operator that gives a brief description about the exception whenever it is applied on a stream.
This section will describe the general JAULA::Exception usage, the derived classes existing in the library and how to extend the exception handling hierarchy for your own purposes.
RSS Feeds