Question

I would like to serve a status 503 error for any of my java appengine servlets which throw an uncaught exception. Currently they throw 500.

More details on why: I have a client application that makes ajax calls to my appengine app. Sometimes appengine itself (not my servlets) will throw 500 errors because something is temporarily wrong with appengine. My application also throws 500 errors when there is an error in my servlet code and and uncaught exception is thrown. I would like for the client to be able to distinguish between the two because for the former it can do a retry where as for the latter it shouldn't. As such, I want my exceptions that are thrown to result in a status code other than 500.

I know I can put a try catch in my doGet and doPost in my servlet but I have a bunch of servlets and don't want to put try catches in every single servlet. Can this be configured somehow?

Was it helpful?

Solution 2

found the answer here: GAE how to see production exceptions?

basically just set a filter that runs first and catches all your exceptions.

OTHER TIPS

GAE/J is basically a Jetty server, have you tried following the steps in How to Create Custom Error Pages at Jetty's doc page?

As a food for thought, I use JAX-RS for my app, and the framework made intercepting exceptions like this is very easy through the use of Exception Mappers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top