EXIT from $parent and signal FAILURE doesn't throw Exception?

Hi,

I hava a Flow Service like this:

SEQUENCE (TRY & CATCH)
    SEQUENCE (TRY)
        ... (do something here)
        BRANCH
            $null: SEQUENCE
                ... (do something here)
                [B]EXIT from $parent and signal FAILURE (I also filled the Failure Message)[/b]

        ... (do something here)

    SEQUENCE (CATCH)
        [B]Invoke: pub.flow:getLastError[/b]
        Invoke: pub.flow:debugLog (The message contains: %lastError/error%)

The problem is: in SEQUENCE (CATCH), the pub.flow:getLastError doesn’t return lastError output, which means the lastError output is null. Suppose it works, the lastError/error should contains the filled Failure Message.

It seems when called EXIT from $parent and signal FAILURE, it doesn’t throw any Exception information for getLastError. Is that true?

On contrary, for the case of EXIT from $flow and signal FAILURE, it will generate exception that can be catched in Catch Sequence (of course, you must have a parent flow service that has try-catch sequence). Then if you call getLastError there, you will get exception information. But for EXIT from $parent and signal FAILURE, the getLastError doesn’t return any exception information. I don’t know why.

Hello,

If you are calling flow service B from A i.e. A is parent to B then you don’t need to have a try catch for B. Did you tried this? and still ‘Exit from $parent and signal failure’ not working?

Thank you,
Anil

And looks like from the code .You do have try catch in your child (service B) . Correct me if my understanding is wrong

It doesn’t matter if service B has try-catch or not, the sure thing is if service B calls “Exit from $flow & signal Failure”, it will throw exception (but usually I will put the “Exit from $flow & signal Failure” in catch sequence). Of course, service A (who calls the service B) should has try-catch to catch the exception.

Btw, that is not my primary topic/question for this thread anyway.

It’s only a single flow service. No service A, no service B.

The topic/question of this thread is about why “EXIT from $parent and signal FAILURE” doesn’t throw Exception Information for getLastError?

For some reason i misread your post.

Normally i custom label the step i want to exit from and signal failure . And it always worked for me.

I found a solution.

Use pub.flow:throwExceptionForRetry in place of EXIT from $parent and signal FAILURE.

Thx to arnaudW.

Since you’re catching the exception thrown by throwExceptionForRetry, there probably is no retry performed. This may lead to confusion for those that edit/maintain this service later.

I had encountered the beahvior of EXIT and signal FAILURE not populating lastError some years back. Because of that I never use EXIT and signal FAILURE. I wrote a simple Java service that accepts a string and throws a ServiceException and I always use that. This is more or less what throwExceptionForRetry does but without the potential confusion of “if I call this will it retry?”

1 Like

Thanks for your explanation. I think I’m gonna use your way :slight_smile:

Well,afer some tests,there must be some problem in the CODE you write.
In the Built-In service refernece,pay attention to the usage notes of “pub.flow:getLastError”,it reads:

“Each execution of a service (whether the service succeeds or fails) updates the value
returned by getLastError. Consequently, getLastError itself resets the value of lastError.
Therefore, if the results of getLastError will be used as input to subsequent services, map
the value of lastError to a variable in the pipeline.”

This means that , in the catch sequence,u can not put any service befre the “pub.flow:getLastError”,including transform used in the MAP!

so ,you’d make sure ,in the catch sequence, there are no services/no transforms in MAP before pub.flow:getLastError,

I suggest to make “pub.flow:getLastError” the first step in the catch sequence.

Hope this will help.
Regards!
Yee.

"I suggest to make “pub.flow:getLastError” the first step in the catch sequence. "

Yes this is the standard way to go in any Catch sequence…

HTH,
RMG

Hi as i see from the first post of yours i saw you are writing all this code under a branch statement with the label as null are you sure the code flows into it ?
if yes the Exit should be properly working , just made a similar and checked with a label chaneg and it worked

In the EXIT step there is a field “Failure message”. You need to fill this with an appropriate error message. So when control passes to the getLastError service your error message will be placed in lastError/error variable. The reason why “Failure message” has to be populated is because webMethods does not know what type of error you have identified so you give some meaningful error string. You can even add in values from other variables using the syntax %myvariable%.

The difference with “EXIT from $flow and signal FAILURE” is telling webMethods to fail the whole service. webMethods then populates lastError/error variable with a flow related error message.

Hi Bromo .

The answer of your question is mentioned in the usage of notes of getLastError service , refer BIS guide .
It says :-

If you are using exit $parent signal failure in a flow service , then in the same flow service , the lastError document will not be updated.