From sling filter, in case of an error we are trying to send back the response code to the browser using SlingHttpServletResponse setStatus method and then forward to error page using RequestDispatcher. Please see the code below for the same -
slingResponse.setStatus(errorCode);
RequestDispatcher dispatch = slingRequest.getRequestDispatcher(redirectURLForErrorPage);
dispatch.forward(slingRequest, slingResponse);
This is working fine if the errorCode is in series of 400 i.e. 401, 404 etc. but its not working for errorCode 500.
If the errorCode is 500, it sends back the 500 error code to browser but does not forward to the error page.
The same code works fine on local for both 400s and 500s error codes but does not work on the cloud environments.
We have tried using dispatch.include and setting larger buffer size, as suggested in some other posts in this community, but that didnt work.
Is this something that is blocked by some dispatcher config in cloud or some other issue, please suggest.
Thanks in advance.