def METHOD_NAME(self, listener):
    try:
        version = int(listener.ROBOT_LISTENER_API_VERSION)
        if version not in (2, 3):
            raise ValueError
    except AttributeError:
        raise DataError("Listener '%s' does not have mandatory "
                        "'ROBOT_LISTENER_API_VERSION' attribute."
                        % self.name)
    except (ValueError, TypeError):
        raise DataError("Listener '%s' uses unsupported API version '%s'."
                        % (self.name, listener.ROBOT_LISTENER_API_VERSION))
    return version