RADException Python Class

This following example shows how to use RADException.

Example 4-1 Using the RADException Python Class

The ADR type definition is as follows:

<struct name="pair" stability="private">
   <field name="first" type="integer"/>
   <field name="second" type="integer"/>
</struct>

The ADR method definition is as follows:

<method name="raiseError" stability="private">
  <doc>
  Raise an exception to test exception handling.
  </doc>
  <error type="pair"/>
</method>

In the method definition, you are specifying that an exception must be raised when the initialization of the struct pair fails.

The implementation is as follows:

def raiseError(self):
    raise radser.RADException(snake_iface.pair(3, 6))

In this example, you are raising a RADException and providing a payload that matches the definition in the ADR document.

The exceptions that occur as a consequence of "other" errors such as divide by zero are propagated back to the client as a CE_SYSTEM error representing the general RAD failure code for systemic failure.