@Override
    public Messages process(Messages messages) {
        try (Timer.Context ignored = executionTime.time()) {
            final State latestState = stateUpdater.getLatestState();
            if (latestState.enableRuleMetrics()) {
                return process(messages, new RuleMetricsListener(metricRegistry), latestState);
            }
            return process(messages, new NoopInterpreterListener(), latestState);
        }
    }
@Test
    public void process_ruleConditionEvaluationErrorConvertedIntoMessageProcessingError() throws Exception {
        // given
        when(ruleService.loadAll()).thenReturn(ImmutableList.of(RuleDao.create("broken_condition", "broken_condition",
                "broken_condition",
                "rule \"broken_condition\"\n" +
                        "when\n" +
                        "    to_double($message.num * $message.num) > 0.0\n" +
                        "then\n" +
                        "    set_field(\"num_sqr\", $message.num * $message.num);\n" +
                        "end", null, null, null, null)));

        when(pipelineService.loadAll()).thenReturn(Collections.singleton(
                PipelineDao.create("p1", "title", "description",
                        "pipeline \"pipeline\"\n" +
                                "stage 0 match all\n" +
                                "    rule \"broken_condition\";\n" +
                                "end\n",
                        Tools.nowUTC(),
                        null)
        ));


        final PipelineInterpreter interpreter = createPipelineInterpreter(ruleService, pipelineService, ImmutableMap.of(
                SetField.NAME, new SetField(),
                DoubleConversion.NAME, new DoubleConversion())
        );

        // when
        final List<Message> processed = extractMessagesFromMessageCollection(interpreter.process(messageWithNumField("ABC")));

        // then
        assertThat(processed)
                .hasSize(1)
                .hasOnlyOneElementSatisfying(m -> {
                    assertThat(m.processingErrors())
                            .hasSize(1)
                            .hasOnlyOneElementSatisfying(pe -> {
                                assertThat(pe.getCause()).isEqualTo(ProcessingFailureCause.RuleConditionEvaluationError);
                                assertThat(pe.getMessage()).isEqualTo("Error evaluating condition for rule <broken_condition/broken_condition> (pipeline <pipeline/p1>)");
                                assertThat(pe.getDetails()).isEqualTo("In call to function 'to_double' at 3:4 an exception was thrown: class java.lang.String cannot be cast to class java.lang.Double (java.lang.String and java.lang.Double are in module java.base of loader 'bootstrap')");
                            });
                });
    }