Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If an execution took an exception in the next runs error message is transfered even if it successes. #590

Open
taskinozdemir opened this issue Mar 1, 2024 · 1 comment

Comments

@taskinozdemir
Copy link

If a workflow took an exception in . In the next run error message is transfered even if It successes. Sample code is stated below.

public class HasException
{
    internal class TestClass
    {
        private int counter = 0;
        private string simpleProp;

        public string SimpleProp {
            get {
                if (counter++ == 0)
                {
                    throw new ArgumentException("Canım istedi");
                }
                return simpleProp;
            }
            set {
                simpleProp = value;
            }
        }
    }

    public void Run()
    {
        Console.WriteLine($"Running {nameof(NestedInputDemo)}....");

        TestClass instance = new();
        instance.SimpleProp = "simpleProp";

        Workflow workflow = new();
        workflow.WorkflowName = "NestedInputDemoWorkflow1";
        workflow.Rules = new List<Rule>() {
            new Rule() {
                RuleName = "CheckNestedSimpleProp",
                RuleExpressionType = RuleExpressionType.LambdaExpression,
                Expression = "SimpleProp == \"simpleProp\"",
                ErrorMessage = "One or more adjust rules failed."
            }
        };

        var settings = new ReSettings();
        settings.UseFastExpressionCompiler = false;
        var bre = new RulesEngine.RulesEngine(new Workflow[] { workflow }, settings);
        var resultList = bre.ExecuteAllRulesAsync(workflow.WorkflowName, instance).Result;
        resultList.OnSuccess((eventName) => {
            Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in success - {eventName}. {resultList[0].ExceptionMessage}");
        }).OnFail(() => {
            Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in failure. {resultList[0].ExceptionMessage}");
        });
        resultList = bre.ExecuteAllRulesAsync(workflow.WorkflowName, instance).Result;
        resultList.OnSuccess((eventName) => {
            Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in success - {eventName}");
        }).OnFail(() => {
            Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in failure");
        });
    }
}
@taskinozdemir
Copy link
Author

I have created a pr for fixing this issue #592. Also I added a unit test to simulate the problem. Can you help us. This is a critical issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant