-
Notifications
You must be signed in to change notification settings - Fork 552
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
EnableExceptionAsErrorMessage = false does not actually throw exception, but ignores/supresses it #624
Comments
Okay tried it with a simple ruie with wrong Success name, ... "OnSuccess": {
"Name": "EvaluateRuleX",
"Context": {
}
}, and when debugging (catching all CLR exceptions), I e.g. land here:
It handles the exception and returns it. At least for such "system exceptions". it's quite obvious there that these are ignored? |
I also reproduced this in your DemoApp -this time using an obvious syntax error in an expression that results in an index 88f9ad9..54e5c95 100644
--- a/demo/DemoApp/JSONDemo.cs
+++ b/demo/DemoApp/JSONDemo.cs
@@ -41,7 +41,10 @@ namespace DemoApp
var fileData = File.ReadAllText(files[0]);
var workflow = JsonConvert.DeserializeObject<List<Workflow>>(fileData);
- var bre = new RulesEngine.RulesEngine(workflow.ToArray(), null);
+ var bre = new RulesEngine.RulesEngine(workflow.ToArray(), new ReSettings() {
+ EnableExceptionAsErrorMessage = false,
+ IgnoreException = false
+ });
string discountOffered = "No discount offered.";
diff --git a/demo/DemoApp/Workflows/Discount.json b/demo/DemoApp/Workflows/Discount.json
index ad556d9..eb3b156 100644
--- a/demo/DemoApp/Workflows/Discount.json
+++ b/demo/DemoApp/Workflows/Discount.json
@@ -8,7 +8,7 @@
"ErrorMessage": "One or more adjust rules failed.",
"ErrorType": "Error",
"RuleExpressionType": "LambdaExpression",
- "Expression": "input1.country == \"india\" AND input1.loyaltyFactor <= 2 AND input1.totalPurchasesToDate >= 5000 AND input2.totalOrders > 2 AND input3.noOfVisitsPerMonth > 2"
+ "Expression": "input1.countr == \"india\" AND input1.loyaltyFactor <= 2 AND input1.totalPurchasesToDate >= 5000 AND input2.totalOrders > 2 AND input3.noOfVisitsPerMonth > 2"
},
{
"RuleName": "GiveDiscount20", Ah okay, if I change it to
Maybe it only affects ActionWorkflows though, where you have no example for in the demo apps as far as I see? |
Also asked a related question about this, because it totally confuses me how many places there are to store some exceptions (or exception messages): #628 |
STR
Have any invalid rule or one that somehow else throws an exception.
And have the settings configured as such:
What should happen
EnableExceptionAsErrorMessage = false
is explained on https://microsoft.github.io/RulesEngine/#settings should do the following:Notably
IgnoreException
is not touched, i.e. it is (as per https://microsoft.github.io/RulesEngine/#settings aka the default set tofalse
)What happens
Errors are silently ignored.
More information
I have also indicated this in #623, see this for a practical example.
System
aka .NET 8
Windows 10
The text was updated successfully, but these errors were encountered: