cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1125
Views
5
Helpful
3
Replies

Handling Exceptions in Custom classes

sreekanth47
Level 4
Level 4

Hello Experts,

 

                    I'm writing a custom action element, which is used to send soap web service request and get the response and put it into session. In my flow , I've used this element when ever web services are required. In one of my flow , I got connectionTImeout exception, occurred at custom action element, the very next element is  decision , using a java class. but in this class I couldn't catch time out exception.The concept is when ever timeout occurred I've to set exit state as timedout.

To achieve this what steps I need to do. Is there any way to throw an exception in custom action class and catch that exception  in studio application.

Thank you.

1 Accepted Solution

Accepted Solutions

janinegraves
Spotlight
Spotlight
You could just recode your web service element as a custom decision, instead of an action. That way you can catch the exception and exit down a failure exit state.

Otherwise, you could recode your web service element and execute the doAction code inside a try/catch. If you catch an exception then set Element Data named 'success' to 'false' (if it succeeds then set that same variable to true). Then follow this with a regular Decision element that checks the Element Data.

If your web service is a 'Configurable Action' element then it has an Events tab. And there you can add an event handler to catch any exception you like (or *.* to catch all exceptions).

If your web service is a 'Standard Action' then it doesn't have an Events tab. You could catch the Java Exceptions on the Start of Call's Events tab. It'll catch all Java exceptions (or you could just catch the timeout exception specifically by name).

Lots of options, depends on how much Studio and Java you know.

View solution in original post

3 Replies 3

janinegraves
Spotlight
Spotlight
You could just recode your web service element as a custom decision, instead of an action. That way you can catch the exception and exit down a failure exit state.

Otherwise, you could recode your web service element and execute the doAction code inside a try/catch. If you catch an exception then set Element Data named 'success' to 'false' (if it succeeds then set that same variable to true). Then follow this with a regular Decision element that checks the Element Data.

If your web service is a 'Configurable Action' element then it has an Events tab. And there you can add an event handler to catch any exception you like (or *.* to catch all exceptions).

If your web service is a 'Standard Action' then it doesn't have an Events tab. You could catch the Java Exceptions on the Start of Call's Events tab. It'll catch all Java exceptions (or you could just catch the timeout exception specifically by name).

Lots of options, depends on how much Studio and Java you know.

thanks Janine, I've used session data to store exception, and handle this exception in decision class.
"If your web service is a 'Configurable Action' element then it has an Events tab. And there you can add an event handler to catch any exception you like (or *.* to catch all exceptions)."

Can I catch java.net.SocketTimeoutException ? if put *.* in Eventlist it will catch all exceptions, should I put java.net.SocketTimeoutException in event list?

if you just want to catch the timeout exception, then list just the one exception. Then test and ensure it works as expected.
You can also catch all Java exceptions *.* on the Start of Call element to catch anything else that might occur.