Class ErrorRedirect
- java.lang.Object
-
- ru.vyarus.guicey.gsp.app.filter.redirect.ErrorRedirect
-
public class ErrorRedirect extends java.lang.ObjectRedirects 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 withTemplateExceptionListenerandTemplateErrorResponseFilter.- Since:
- 07.12.2018
-
-
Field Summary
Fields Modifier and Type Field Description static intCODE_400static intDEFAULT_ERROR_PAGESpecial code for default error page registration (ServerPagesAppBundle.AppBuilder.errorPage(String)).
-
Constructor Summary
Constructors Constructor Description ErrorRedirect(java.lang.String appMapping, java.util.Map<java.lang.Integer,java.lang.String> pages, SpaSupport spa)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static jakarta.ws.rs.WebApplicationExceptiongetContextError()Note: method is not supposed to be used directly as error object is directly available in model:ErrorTemplateView.getError().static java.lang.StringgetContextErrorOriginalUrl()Returned string isrequest.getRequestURI()from original request.static booleanhasContextError()booleanredirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.ws.rs.WebApplicationException exception)Try to redirect error to configured error page.
-
-
-
Field Detail
-
DEFAULT_ERROR_PAGE
public static final int DEFAULT_ERROR_PAGE
Special code for default error page registration (ServerPagesAppBundle.AppBuilder.errorPage(String)).- See Also:
- Constant Field Values
-
CODE_400
public static final int CODE_400
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ErrorRedirect
public ErrorRedirect(java.lang.String appMapping, java.util.Map<java.lang.Integer,java.lang.String> pages, SpaSupport spa)
-
-
Method Detail
-
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- requestresponse- responseexception- 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 java.lang.String getContextErrorOriginalUrl()
Returned string isrequest.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
-
-