r"""
    Add an exception in the global exception handler.

    :param extype: Exception type; *must* be derived from the `Exception
                   <https://docs.python.org/2/library/exceptions.html#
                   exceptions.Exception>`_ class
    :type  extype: Exception type object, i.e. RuntimeError, TypeError,
                   etc.

    :param exmsg: Exception message; it can contain fields to be replaced
                  when the exception is raised via
                  :py:meth:`pexdoc.ExHandle.raise_exception_if`.
                  A field starts with the characters :code:`'\*['` and
                  ends with the characters :code:`']\*'`, the field name
                  follows the same rules as variable names and is between
                  these two sets of characters. For example,
                  :code:`'\*[fname]\*'` defines the fname field
    :type  exmsg: string

    :param condition: Flag that indicates whether the exception is
                      raised *(True)* or not *(False)*. If None the
                      flag is not used an no exception is raised
    :type  condition: boolean or None

    :param edata: Replacement values for fields in the exception message
                  (see :py:meth:`pexdoc.ExHandle.add_exception` for how
                  to define fields). Each dictionary entry can only have
                  these two keys:

                  * **field** *(string)* -- Field name

                  * **value** *(any)* -- Field value, to be converted into
                    a string with the `format
                    <https://docs.python.org/2/library/stdtypes.html#
                    str.format>`_ string method

                  If None no field replacement is done

    :rtype: (if condition is not given or None) function

    :raises:
     * RuntimeError (Argument \`condition\` is not valid)

     * RuntimeError (Argument \`edata\` is not valid)

     * RuntimeError (Argument \`exmsg\` is not valid)

     * RuntimeError (Argument \`extype\` is not valid)

def addex(extype, exmsg, condition=None, edata=None):
    r"""
    Add an exception in the global exception handler.

    :param extype: Exception type; *must* be derived from the `Exception
                   <https://docs.python.org/2/library/exceptions.html#
                   exceptions.Exception>`_ class
    :type  extype: Exception type object, i.e. RuntimeError, TypeError,
                   etc.

    :param exmsg: Exception message; it can contain fields to be replaced
                  when the exception is raised via
                  :py:meth:`pexdoc.ExHandle.raise_exception_if`.
                  A field starts with the characters :code:`'\*['` and
                  ends with the characters :code:`']\*'`, the field name
                  follows the same rules as variable names and is between
                  these two sets of characters. For example,
                  :code:`'\*[fname]\*'` defines the fname field
    :type  exmsg: string

    :param condition: Flag that indicates whether the exception is
                      raised *(True)* or not *(False)*. If None the
                      flag is not used an no exception is raised
    :type  condition: boolean or None

    :param edata: Replacement values for fields in the exception message
                  (see :py:meth:`pexdoc.ExHandle.add_exception` for how
                  to define fields). Each dictionary entry can only have
                  these two keys:

                  * **field** *(string)* -- Field name

                  * **value** *(any)* -- Field value, to be converted into
                    a string with the `format
                    <https://docs.python.org/2/library/stdtypes.html#
                    str.format>`_ string method

                  If None no field replacement is done

    :rtype: (if condition is not given or None) function

    :raises:
     * RuntimeError (Argument \`condition\` is not valid)

     * RuntimeError (Argument \`edata\` is not valid)

     * RuntimeError (Argument \`exmsg\` is not valid)

     * RuntimeError (Argument \`extype\` is not valid)
    """
    return _ExObj(extype, exmsg, condition, edata).craise