Does anyone have a convenient existing solution for error handling that considers the incoming request file extension when resolving which script to use to render the error response?
For example, I am expecting that a request to http://localhost:8080/bogus.json should return a JSON response with the 404 error details in JSON when the resource doesn't exist. (also similar behavior should be possible for a .txt or .xml file extension) What I see currently is that SlingServletResolver#handleError ignores the incoming file extension and always returns the error page as html. I would expect that an "errorhandler" script/servlet registered with ("sling.servlet.resourceTypes=sling/servlet/errorhandler", "sling.servlet.extensions=json", "sling.servlet.methods=404") should be preferred when the incoming request has a .json extension, and then use the original html error response as a fallback for all other scenarios. Basically I would like to have the client get JSON back when something goes wrong instead of html that won't parse as JSON. If no one disagrees, I can open a bug report and provide the proposed changes to org.apache.sling.servlets.resolver Regards, Eric
