You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because of #624 I need to the results whether an exception occurred. I basically want to extract one or all?
I have implemented it like this and wonder, whether this is really needed?
As you can see, there are multiple places, where an exception can be defined, sometimes as a string, sometimes a real Exception:
1, The global ActionRuleResult.
2. each RuleResultTree has a string of it.
3. each RuleResultTree also can have an ActionResult though, which also has it?
4. And then, (only with sub.rules AFAIK?), we can have even more exceptions in a recursive manner, in the ActionResult if this is itself an ActionRuleResult...
publicstaticboolAnyRuleHasException(thisActionRuleResultresult,outException?collectedExceptions){IEnumerable<Exception>exceptions=[];// first in data type: it has a global Exceptionif(result.Exceptionis not null){exceptions=exceptions.Append(result.Exception);}foreach(varruleResultinresult.Results){// then, in each RuleResultTree we have another place to store exceptions:if(!string.IsNullOrEmpty(ruleResult.ExceptionMessage)){varexception=newRuleException(ruleResult.ExceptionMessage);exceptions=exceptions.Append(exception);}// then, yet again, in each RuleResultTree there is a ActionResult, which can also have an exceptionif(ruleResult.ActionResult?.Exceptionis not null){exceptions=exceptions.Append(ruleResult.ActionResult.Exception);}if(ruleResult.ActionResultisActionRuleResult){// not implemented: recursive exception check }}varallCollectedExceptions=exceptions.ToList();switch(allCollectedExceptions.Count){case1:collectedExceptions=allCollectedExceptions.First();returntrue;case>1:collectedExceptions=newAggregateException($"Multiple {nameof(RuleException)}s happened. See InnerException for details.",allCollectedExceptions);returntrue;default:collectedExceptions=null;returnfalse;}}
I feel this is way to complicated, but there is also no doc about where/which exception si stored. Or is it always enough to evaluate the top-level one? And if so, what happens if there are multiple exceptions? Are they stored? Is the AggregateException I manually create here even needed and I have it anyway etc. etc.?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Because of #624 I need to the results whether an exception occurred. I basically want to extract one or all?
I have implemented it like this and wonder, whether this is really needed?
As you can see, there are multiple places, where an exception can be defined, sometimes as a string, sometimes a real
Exception
:1, The global
ActionRuleResult
.2. each
RuleResultTree
has a string of it.3. each
RuleResultTree
also can have anActionResult
though, which also has it?4. And then, (only with sub.rules AFAIK?), we can have even more exceptions in a recursive manner, in the
ActionResult
if this is itself anActionRuleResult
...I feel this is way to complicated, but there is also no doc about where/which exception si stored. Or is it always enough to evaluate the top-level one? And if so, what happens if there are multiple exceptions? Are they stored? Is the
AggregateException
I manually create here even needed and I have it anyway etc. etc.?Beta Was this translation helpful? Give feedback.
All reactions