MXM Exceptions

In order to differentiate the types of exception that may occur at runtime in a MXM enviroment, we defined the following specialization: InvalidStateException, NoDataException, InvalidTypeException, InvalidDataException and NoImplementedMethodException. 
In MXM Exception class, we define a particular collection of exceptions types. These are presented

MXMException :thrown when it is not known a priori what exception type will be
NoDataException: thrown when attempting to reference an empty data structure
InvalidDataException :thrown when attempting to save or retrieve information of a data structure that is invalid
InvalidTypeException: thrown when attempting to process an invalid type data structure
InvalidStateException: thrown when attempting to change the state of an object, to a state that is not defined for that object
NotImplementedException: thrown when attempting to use a method which is defined in the interface but not implemented yet
UserDefinedException: the root exception to be extended by user-defined exceptions, in order to handle those exceptions which might be particular for a user’s application

MXM C++ Exception hierarchy

Proposed macro functions
We also propose adding two macros: MXMThrow and MXMCaught, whose purpose is to perform specific operations in order to handle an MXMException. These macros can only handle exceptions of class MXMException and those classes derived from it.

MXMThrow macro takes as parameter the logger of the application which has thrown the exception, the exception type and user-defined information. By passing the logger parameter to the MXMThrow macro, we enable the detection of the class and the line number where the code throwing the exception resides.
MXMCaught may be called to log the catch-point of an exception: using MXMThrow and MXMCaught, it is possible to trace exception paths and bounce, which is very helpful at debug time. The MXMCaught macro takes as an input parameter the logger of the application which handles the exceptions, and the exception itself, which can be one of those defined in table 1.

A use case
In what follows, we provide an example of how to use the MXMThrow macro.
MXMThrow sequentially makes two operations: log and throw.

Taking this into consideration, for a situation of this type

{
   < code >
   if (everything ok)
   { < code > }
else
       { MXMThrow( …. ); }
   < other code >
}

the macro is correctly used. Note that, the macro has to be between brackets.

The macro is also valid in a situation of this type:

else
       {  
          < various code >
          MXMThrow( …. ); 
       }

Meanwhile, in a situation of the following type:

{
   < code >
   if (everything ok )
   { < code > }
   else
       MXMThrow( …. );

   < other code >
}

after the macro expansion, the above code becomes:

{
   < code >
   if (everything ok )
   { < code > }
   else
       LOG4CXX_DEBUG( …. );
   throw …;
   < other code >
}

which is not what we wanted, because ”” is not executed anymore.

-->