Exceptions

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.


(c) 2007 Kombo Morongo.

Unless otherwise stated for scpecific contents of this site, permission is granted to copy, distribute and/or modify the contents of this site under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation. A copy of the license is included in the section entitled "GNU Free Documentation License".

Powered by Drupal - Modified by Danger4k