One Star

Global Try/Catch

Hello,
I would ask if there's a way to put a global try/catch to be sure that job will not crash and we can (eventually) display the error later (maybe just put it in the global map).
Is it possible a new component to be created, which would put/generate (for example) try/catch in runJobInTOS method?
Thank you,
Kostadin
3 REPLIES
One Star

Re: Global Try/Catch

There are many ways to accomplish your goals, but I found the best way to tackle the issues your seeing is:
1. Click on code to expand it in the left pane (repository).
2. On routines right click create
3. Create your custom routines with a try catch, then start using it in your tMap
----------
Then make a tLogRow, rightclick on a tMap and choose row -> rejects and then click on the tLogRow. You can choose how you want to deal with these later, but the best practical method in my mind is to:
Create a tAssetCatcher linked to a tMap which is linked to a database table input object. Do the mapping in the tMap and now you have the error results going to a database table.
Seventeen Stars

Re: Global Try/Catch

If you use your job as an embedded job, in this case you can specify if the main job should fail or not if the mebedded job fails.
One Star

Re: Global Try/Catch

Thank you for your answers.
We use the job as a subjob, but the problem is that our process should not ends when the subjob crashes. That's why uncheck of "Die on child error" doesn't work.
However I found something that worked for me: tRunJob--->tJavaRow and the code is something like:
if (childJob_tRunJob_1.getException() == null) {
...} else {...}
I found that when the the subjob crash doesn't ends the process ("Die on child error" - unchecked) getException() returns the exception and in a non-crash case it's just null.