Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Could you guys help me understand how do I abort my job when tRest return an error. I tried doing Run IF -->tDie directly from tRest
((String)globalMap.get("tREST_1_ERROR_MESSAGE")).length() >0
but that results in NPE
Error on line 1 of document : Premature end of file. Nested exception: Premature end of file. Exception in component tREST_1 java.lang.NullPointerException
So now I'm using tMap to separate Body from ERROR_MESSAGE. I can't figure out what to do with error row though. I can't use "Run If" trigger directly with tMap:
What is the typical way of handling error from REST call?
Thanks,
Dima
There's a few ways to do what you want. The reason you're getting a NPE is because Talend will evaluate the "if" links when the component they are attached to runs their "end" section -- since the subjob with your tREST component has not even initialized at this point, the globalMap key will not be populated and the get will return null.
Here's a quick example of two ways to do what you want:
1) use onSubJobError off the tREST subjob
or
2) use a stub component to ensure the tREST subjob is complete before evaluating your if statement
I tried doing a OnSubjobError but tDie is not triggered. I can catch ERROR_CODE though
Here's my tMap just in case
I'm having the same issue. Is there a solution for this?