How do you go about catching this exception in a servlet that takes longer than 30 seconds?
Thanks!
How do you go about catching this exception in a servlet that takes longer than 30 seconds?
Thanks!
You can use a normal try-catch around your code and catch the DeadlineExceededException:
import com.google.apphosting.api.DeadlineExceededException
try {
// your code
} catch (DeadlineExceededException e) {
// do something here to handle the exception in a user-friendly way
}
Do remember that your time available after catching the DeadlineExceededException is limited. So you can't execute a lot of code inside the catch, because it will generate a HardDeadlineExceededError after a short period (generally < 1 sec).
So use it wisely and just return a message to user or do a quick cleanup to rollback anything if necessary.