Class ErrorRedirect
java.lang.Object
ru.vyarus.guicey.gsp.app.filter.redirect.ErrorRedirect
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intSpecial code for default error page registration (ServerPagesAppBundle.AppBuilder.errorPage(String)). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic jakarta.ws.rs.WebApplicationExceptionNote: method is not supposed to be used directly as error object is directly available in model:ErrorTemplateView.getError().static StringReturned string isrequest.getRequestURI()from original request.static booleanbooleanredirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.ws.rs.WebApplicationException exception) Try to redirect error to configured error page.
-
Field Details
-
DEFAULT_ERROR_PAGE
public static final int DEFAULT_ERROR_PAGESpecial code for default error page registration (ServerPagesAppBundle.AppBuilder.errorPage(String)).- See Also:
-
CODE_400
public static final int CODE_400- See Also:
-
-
Constructor Details
-
ErrorRedirect
-
-
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- 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
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
-