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
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?
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
2) use a stub component to ensure the tREST subjob is complete before evaluating your if statement
Introduction to Talend Open Studio for Data Integration.
Practical steps to developing your data integration strategy.
Create systems and workflow to manage clean data ingestion and data transformation.