0

I am using Embedded Jetty in my Java project. I am throwing RuntimeException at few places but they are resulting in 500 error code and raw html is returned in response.

My application is rest API application, so I want to return Exception message to client in JSON format.

I tried ErrorHandler class but I am not getting how to get thrown Exception in this class. Please help me with this.

ServletContextHandler jettyHandler =
        new ServletContextHandler(jettyServer, "/");
jettyHandler.setErrorHandler(new ErrorHandler());
Shashwat Kumar
  • 5,159
  • 2
  • 30
  • 66

0 Answers0