Class ErrorTemplateView
- java.lang.Object
-
- io.dropwizard.views.View
-
- ru.vyarus.guicey.gsp.views.template.TemplateView
-
- ru.vyarus.guicey.gsp.views.template.ErrorTemplateView
-
public class ErrorTemplateView extends TemplateView
Error template rendering model. Must be used for error pages (registered in main bundleServerPagesAppBundle.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.
TracelessExceptionto 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
Constructors Constructor Description ErrorTemplateView()ErrorTemplateView(java.lang.String templatePath)ErrorTemplateView(java.lang.String templatePath, java.nio.charset.Charset charset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.ws.rs.WebApplicationExceptiongetError()Returns exception object only during rendering of configured error page (fromServerPagesAppBundle.AppBuilder.errorPage(int, String)).intgetErrorCode()Shortcut forgetError().getResponse().getStatus().java.lang.StringgetErroredUrl()Note returned only uri part (request.getRequestURI()).java.lang.StringgetErrorTrace()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
getContext
-
-
-
-
Method Detail
-
getError
public javax.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:
getError()
-
getErrorTrace
public java.lang.String 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:
getError()
-
getErroredUrl
public java.lang.String getErroredUrl()
Note returned only uri part (request.getRequestURI()).- Returns:
- page url cause redirect to error page
-
-