Class ErrorTemplateView
java.lang.Object
io.dropwizard.views.common.View
ru.vyarus.guicey.gsp.views.template.TemplateView
ru.vyarus.guicey.gsp.views.template.ErrorTemplateView
Error template rendering model. Must be used for error pages (registered in main bundle
ServerPagesAppBundle.AppBuilder.errorPage(int, String)). Provides access to
original error and original (failed) page url (note that it can't be taken from current context request because
error page is rendered as usual page and so current request will contain error page url only).
There are 3 possible exception cases:
AssetErrorfor static asset serving errorTemplateRestCodeErrorfor error code directly returned from rest without throwing exception (e.g.Response.status(404).build())- Any exception extending
WebApplicationException. This is exactly exception thrown in rest method or simple exception wrapped withWebApplicationException.
TracelessException to
simplify detection of exception with meaningful trace.
Note: in contrast to usual templates, during error page rendering context request will contain error page path,
but original url is still available with getErroredUrl().
- Since:
- 31.01.2019
-
Constructor Summary
ConstructorsConstructorDescriptionErrorTemplateView(String templatePath) ErrorTemplateView(String templatePath, Charset charset) -
Method Summary
Modifier and TypeMethodDescriptionjakarta.ws.rs.WebApplicationExceptiongetError()Returns exception object only during rendering of configured error page (fromServerPagesAppBundle.AppBuilder.errorPage(int, String)).intShortcut forgetError().getResponse().getStatus().Note returned only uri part (request.getRequestURI()).Method intended to be used in very simple error pages in order to quickly show stacktrace.Methods inherited from class ru.vyarus.guicey.gsp.views.template.TemplateView
getContextMethods inherited from class io.dropwizard.views.common.View
getCharset, getTemplateName
-
Constructor Details
-
ErrorTemplateView
public ErrorTemplateView() -
ErrorTemplateView
-
ErrorTemplateView
-
-
Method Details
-
getError
public jakarta.ws.rs.WebApplicationException getError()Returns exception object only during rendering of configured error page (fromServerPagesAppBundle.AppBuilder.errorPage(int, String)). For all other cases (from error pages) method is useless.- Returns:
- exception object or null (for normal template rendering)
-
getErrorCode
public int getErrorCode()Shortcut forgetError().getResponse().getStatus(). Shortcut created because direct expression can't be used in freemarker expression.- Returns:
- status code from context error or -1 if no context error
- See Also:
-
getErrorTrace
Method intended to be used in very simple error pages in order to quickly show stacktrace.Note that in case of direct error code return (404, 500 etc) exception will be "empty" (exception instance will be created but not thrown).
- Returns:
- current stacktrace as string or null if no context error
- See Also:
-
getErroredUrl
Note returned only uri part (request.getRequestURI()).- Returns:
- page url cause redirect to error page
-