Is there a way I can do this? If i build a flowchart I can just leave one side of a decision blank and it will follow that route and exit. But in a sequence I need IF activities around it all to make it “do nothing” and that often makes the sequence hard to read when you need to nest them. Having an IF with just a Throw in it looks nice and clean and makes it skip the rest of the sequence below but it raises an error, and I don’t want to catch these cases as systemexceptions or businessruleexceptions since I need to preserve it for real errors.
This may not be the absolute solution, but this came to my mind right away.
You can use throw inside an If condition but make sure to throw as the exception which 100% will not appear in that xaml and catch the exception with the corresponding catch.
In this way, you are not messing up with System.Exception and BusinessRuleException, also the flow gets ended as we want.
Hope this helps.
Happy coding!
Thanks Udhay, byut I’m not sure I’m following you and how it helps. I will of course use an IF to determine if I should “leave” this sequence or not - the question is in what way I cancel the rest of the activities. Using a throw still raises an error and that’s what I would like to avoid.
My thought is like we use a throw inside an If statement and using something like
new DivideByZeroException() (or some other specific type of exception which will never occur in the flow)
and then catching it with the correct catch and leaving the catch empty.
In this way, the flow is ended and we dont want to use systemexceptions or businessruleexceptions, I believe thats the requirement we want.
Kindly correct me if I am wrong.
Yes, that sounds like something I too figured would work! I wasn’t sure of what type of error to use but I guess you can take anyone except systemexception or BRE.
Would you consider it to be a problem that we throw errors “unnecessarily”? I’m thinking for log purposes etc.