Class ErrorRedirect

java.lang.Object
ru.vyarus.guicey.gsp.app.filter.redirect.ErrorRedirect

public class ErrorRedirect extends Object
Redirects response error to the configured error page (ServerPagesAppBundle.AppBuilder.errorPage(String)). Only response codes >= 400 (errors) are handled, everything else considered as normal flow.

When SPA support is enabled, also intercept all 404 errors and checks if it could be SPA route (and do home redirect instead of error).

Asset errors are intercepted directly inside ServerPagesFilter. Rest errors are intercepted with TemplateExceptionListener and TemplateErrorResponseFilter.

Since:
07.12.2018
  • Field Details

  • Constructor Details

  • Method Details

    • redirect

      public boolean redirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.ws.rs.WebApplicationException exception)
      Try to redirect error to configured error page.
      Parameters:
      request - request
      response - response
      exception - error (either simple wrapping for error code or complete stacktrace from rest)
      Returns:
      true if error page found and false if no page configured (no special handling required)
    • getContextError

      public static jakarta.ws.rs.WebApplicationException getContextError()
      Note: method is not supposed to be used directly as error object is directly available in model: ErrorTemplateView.getError().
      Returns:
      thread bound exception to use in error page rendering or null if no error bound
    • getContextErrorOriginalUrl

      public static String getContextErrorOriginalUrl()
      Returned string is request.getRequestURI() from original request.
      Returns:
      url of original page (before redirect to error page)
    • hasContextError

      public static boolean hasContextError()
      Returns:
      true indicate error page rendering, false in all other cases