I would like to do some custom logic anytime there is an uncaught exception in my application. Normally I would do something like:
Thread.setDefaultUncaughtExceptionHandler(myCustomHandler);
However, Thread
is locked down on Google App Engine. The above code raises a security exception. Is there anyway to achieve similar functionality on Google App Engine?
EDIT: I have implemented my approach as a Servlet Filter. My experience with Java web programming is fairly limited. Can someone comment on such an approach? Since all requests in AppEngine originate as HTTP requests, I think this is a comprehensive solution.
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
try {
chain.doFilter(request, response);
} catch (RuntimeException ex) {
// Work my magic here...
throw ex;
}
}