Each Slice exception is mapped to a C++ class with the same name. For each exception member, the corresponding class contains a public data member. (Obviously, because
BadTimeVal and
BadZoneName do not have members, the generated classes for these exceptions also do not have members.)
Each exception has a default constructor. This constructor performs memberwise initialization; for simple built‑in types, such as integers, the constructor performs no initialization, whereas complex types, such as strings, sequences, and dictionaries are initialized by their respective default constructors.
An exception also has a second constructor that accepts one argument for each exception member. This constructor allows you to instantiate and initialize an exception in a single statement, instead of having to first instantiate the exception and then assign to its members. For derived exceptions, the constructor accepts one argument for each base exception member, plus one argument for each derived exception member, in base-to-derived order.
Note that the generated exception classes contain other member functions that are not shown on
page 200. However, those member functions are internal to the C++ mapping and are not meant to be called by application code.
Ice::Exception forms the root of the exception inheritance tree. Apart from the usual
ice_name,
ice_clone, and
ice_throw member functions, it contains the
ice_print member functions.
ice_print prints the name of the exception. For example, calling
ice_print on a
BadTimeVal exception prints:
For Ice run time exceptions, ice_print also shows the file name and line number at which the exception was thrown.