Ask Your Question
1

How can I prevent Jython exception from stopping the pipeline?

asked 2019-01-08 14:38:50 -0500

TxRyan gravatar image

updated 2019-01-09 23:52:20 -0500

Maithri gravatar image

When I get an exception in my Jython Processor, the Pipeline terminates. I would like to capture the exception and write to log (am doing this), but then I want the pipeline to move on to the next record.

In my Jython now, I have a try...except per the documentation, but any exception halts the entire pipeline.

try:
...
except Exception as e:
  error.write(record, str(e))
edit retag flag offensive close merge delete

Comments

Hi! I believe it depends on the exception and also what's selected for "On Record Error" on Jython Evaluator processor. I am assuming you have try...except block within the for...loop that iterates through all records?

iamontheinet gravatar imageiamontheinet ( 2019-01-08 16:13:31 -0500 )edit

Right now, the "On Record Error" is set to Discard. Yes, I have the "try" inside of the "for record in records:" loop.

TxRyan gravatar imageTxRyan ( 2019-01-08 16:57:03 -0500 )edit
1

Can you provide a way for me to reproduce this scenario on my end? Sample input (without any personal, sensitive info.), any *non-default* settings for the pipeline as well as other processors and Jython code.

iamontheinet gravatar imageiamontheinet ( 2019-01-08 17:03:29 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-01-14 12:21:59 -0500

TxRyan gravatar image

Closing the loop on this one. The code I inherited was using:

try:
except Exception as e:

That wasn't working because the exception I was getting was an IOException and it does not get caught with the above code and thus the pipeline terminates. The two options to resolve it are as follows...

try:
except:

This works as it will trap any exception of ANY type since nothing is explicitly specified. However, you may want to trap specific exceptions and log them differently...

from java.io import IOException
try:
except (IOException, Exception) as e:

This one augments the original code to explicitly look for the IOException. Thus, the error is caught and processing my continue without terminating the pipeline.

edit flag offensive delete link more

Comments

Awesome. Thanks for the update!

iamontheinet gravatar imageiamontheinet ( 2019-01-14 12:31:15 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-01-08 14:38:50 -0500

Seen: 77 times

Last updated: Jan 14