def _create_rule_enforcement(self, failure_reason, exc):
        """
        Note: We also create RuleEnforcementDB for rules which failed to match due to an exception.

        Without that, only way for users to find out about those failes matches is by inspecting
        the logs.
        """
        failure_reason = (
            'Failed to match rule "%s" against trigger instance "%s": %s: %s'
            % (
                self.rule.ref,
                str(self.trigger_instance.id),
                failure_reason,
                str(exc),
            )
        )
        rule_spec = {
            "ref": self.rule.ref,
            "id": str(self.rule.id),
            "uid": self.rule.uid,
        }
        enforcement_db = RuleEnforcementDB(
            trigger_instance_id=str(self.trigger_instance.id),
            rule=rule_spec,
            failure_reason=failure_reason,
            status=RULE_ENFORCEMENT_STATUS_FAILED,
        )

        try:
            RuleEnforcement.add_or_update(enforcement_db)
        except:
            extra = {"enforcement_db": enforcement_db}
            LOG.exception("Failed writing enforcement model to db.", extra=extra)

        return enforcement_db

        Note: We also create RuleEnforcementDB for rules which failed to match due to an exception.

        Without that, only way for users to find out about those failes matches is by inspecting
        the logs.
        
st2reactor/st2reactor/rules/filter.py