Page 1 of 1

Iterating through all phrases of an exception

Posted: Fri Nov 13, 2020 12:35 pm
by Nrhoades
Hi,

I'm trying to figure out how to get the very last phrase in a commitment exception with nested phrases.

For example:

I have a list of exceptions and Ill get the last exception in the list of exceptions as such,

IOrderItem previousException = (IOrderItem)newExceptions[newExceptions.Count-1];

Lets say this returns an exception that has a child phrase, and that child phrase is another exception, and then that child has a phrase that is an exception. How would I get the very last child phrase in this exception with nested child phrases (exceptions)?

Re: Iterating through all phrases of an exception

Posted: Fri Nov 13, 2020 12:47 pm
by BobRichards
We do not have any special search capability in this area. You will have to do it brute-force with some ugly logic. Sorry.

Re: Iterating through all phrases of an exception

Posted: Fri Nov 13, 2020 1:51 pm
by Nrhoades
Not a problem. More specifically I was looking for the logic to pull a child phrase from its parent.
I've tried this:

var phrases = exception.GetProperty["Phrases"];

var childException = phrases[0];

with no such luck. Would you be able to provide an example? Thanks.

Re: Iterating through all phrases of an exception

Posted: Sat Nov 14, 2020 5:19 pm
by BobRichards
Did you get an error? If so, what was it.

Did you cast the "exception.GetProperty["Phrases"];" to an IList so it can be indexed in the next line?