def make_application_error(name, tag):
    """
    Create and return a **class** inheriting from :class:`.xso.XSO`. The
    :attr:`.xso.XSO.TAG` is set to `tag` and the class’ name will be `name`.

    In addition, the class is automatically registered with
    :attr:`.Error.application_condition` using
    :meth:`~.Error.as_application_condition`.

    Keep in mind that if you subclass the class returned by this function, the
    subclass is not registered with :class:`.Error`. In addition, if you do not
    override the :attr:`~.xso.XSO.TAG`, you will not be able to register
    the subclass as application defined condition as it has the same tag as the
    class returned by this function, which has already been registered as
    application condition.
    """
    cls = type(xso.XSO)(name, (xso.XSO,), {
        "TAG": tag,
    })
    Error.as_application_condition(cls)
    return cls