Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
nickheidke
Contributor III
Contributor III

Does using OnComponentError prevent an error from being thrown?

In my main job, I have OnComponentError routed to tDie components in a few places. I also have a joblet set up to listen to Java Exceptions via the tLogCatcher. The joblet handles emailing, logging, and also has a tDie component at the end of it so the job completely ends on exception. My question is, if I have OnComponentError coming off a particular component, and that component fails, will it still throw an Exception for my joblet to catch or will it go to the tDie component and not hit my joblet.

 

My desired behavior is for all exceptions/errors to trigger the joblet so that errors get logged and emails triggered. I'm wondering if I need to avoid using "OnComponentError" flows altogether then or not.

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable

if you take a peek at the generated java you can see that onComponentError links create try/catch blocks that will trap errors in the component. Unless you re-throw the exception after the onComponentError link, the tLogCatcher component will not see the errors

View solution in original post

3 Replies
Anonymous
Not applicable

if you take a peek at the generated java you can see that onComponentError links create try/catch blocks that will trap errors in the component. Unless you re-throw the exception after the onComponentError link, the tLogCatcher component will not see the errors
nickheidke
Contributor III
Contributor III
Author

That's super helpful, thank you!!

 

If I wanted to re-throw the error, which component would I use to do that?

Anonymous
Not applicable

a tJava component with something like this in it should do it for you. You'll need to double check the globalMap key's your components or jobs populate to make sure you get the right error messages. 

 

throw new RuntimeException(((String)globalMap.get("<component_id>_ERROR_MESSAGE")));

 

depending on how your job is connected, you may need to wrap the throw statement in an "if" to prevent the unreachable code compile error:

 

if( true ) { 

    //throw exceptions

}