The ancestor of all exceptions is exceptions.Exception, from which
Ice.Exception is derived.
Ice.LocalException and
Ice.UserException are derived from
Ice.Exception and form the base for all run-time and user exceptions.
Each Slice exception is mapped to a Python class with the same name. The inheritance structure of the Slice exceptions is preserved for the generated classes, so
BadTimeVal and
BadZoneName inherit from
GenericError.
Each exception member corresponds to an attribute of the instance, which the constructor initializes to a default value appropriate for its type. You can also declare different default values for members of primitive and enumerated types, as discussed in
Section 4.10.2. Although
BadTimeVal and
BadZoneName do not declare data members, their constructors still accept a value for the inherited data member
reason in order to pass it to the constructor of the base exception
GenericError.
Each exception also defines the ice_name method to return the name of the exception, and the special method
__str__ to return a stringified representation of the exception and its members.
All user exceptions are derived from the base class Ice.UserException. This allows you to catch all user exceptions generically by installing a handler for
Ice.UserException. Similarly, you can catch all Ice run-time exceptions with a handler for
Ice.LocalException, and you can catch all Ice exceptions with a handler for
Ice.Exception.