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.
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?
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?
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?â
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.
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.