def METHOD_NAME(self, rule_info, rec):
    expr = rule_info.code
    space = self._exception_rule_eval_context(rec)
    try:
        safe_eval(
            expr, space, mode="exec", nocopy=True
        )  # nocopy allows to return 'result'
    except Exception as e:
        _logger.exception(e)
        raise UserError(
            _(
                "Error when evaluating the exception.rule"
                " rule:\n %(rule_name)s \n(%(error)s)"
            )
            % {"rule_name": rule_info.name, "error": e}
        ) from e
    return space.get("failed", False)