Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

trigger tDie for ERROR_MESSAGE in tRest

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:

0683p000009Lr1x.png

 

What is the typical way of handling error from REST call?

 

Thanks,

Dima

Labels (1)
4 Replies
Anonymous
Not applicable
Author

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

 

0683p000009LrEL.png

 

Anonymous
Not applicable
Author

I tried doing a OnSubjobError but tDie is not triggered. I can catch ERROR_CODE though

0683p000009LrEV.png

Here's my tMap just in case

0683p000009Lr7a.png

Anonymous
Not applicable
Author

I tried using another approach suggested with tJava component but it fails with error:

tJava_1 null

 

Edith1
Creator
Creator

I'm having the same issue. Is there a solution for this?