Jetty is helping my application too much. Whenever some unhandled Exception leaks out the top, Jetty takes it upon itself to build a very verbose response and spam it onto my clients
HTTP/1.1 500 com.mongodb.MongoException: No replica set members available in [ { address:'localhost/127.0.0.1:27017', ok:true, ping:0.49878865, isMaster:false, isSecondary:true, setName:dmReplSet, maxBsonObjectSize:16777216, },{ address:'localhost/127.0.0.1:27018', ok:true, ping:0.2565605, isMaster:false, isSecondary:true, setName:dmReplSet, maxBsonObjectSize:16777216, } ] for { "mode" : "primary"}
along with 14K of stacktrace wrapped in a very nice HTML page. The problem is, I don't want the details of the issue leaking out to the clients and, further, this is a JSON Web App accepting and emitting application/json content NOT the HTML Jetty has decided my clients want. I would like to suppress this default error handling having Jetty emit just that standard HTTP 500 response
HTTP/1.1 500 Internal Server Error
and no body at all. How do I get this done? It seems like I should be able to just tell Jetty to "no error page" in etc/jetty.xml or etc/jetty-webdefault.xml or something.
So this seems most easily solved without binding myself to Jetty too much by <error-page> in web.xml
Implementing ErrorHandler like
It isn't pretty, but it works.