public class ErrorTemplateView extends TemplateView
ServerPagesBundle.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:
AssetError for static asset serving errorTemplateRestCodeError for error code directly returned
from rest without throwing exception (e.g. Response.status(404).build())WebApplicationException. This is exactly exception thrown in rest method
or simple exception wrapped with WebApplicationException.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().
| Constructor and Description |
|---|
ErrorTemplateView() |
ErrorTemplateView(java.lang.String templatePath) |
ErrorTemplateView(java.lang.String templatePath,
java.nio.charset.Charset charset) |
| Modifier and Type | Method and Description |
|---|---|
javax.ws.rs.WebApplicationException |
getError()
Returns exception object only during rendering of configured error page
(from
ServerPagesBundle.AppBuilder.errorPage(int, String)). |
int |
getErrorCode()
Shortcut for
getError().getResponse().getStatus(). |
java.lang.String |
getErroredUrl()
Note returned only uri part (
request.getRequestURI()). |
java.lang.String |
getErrorTrace()
Method intended to be used in very simple error pages in order to quickly show stacktrace.
|
getContextpublic ErrorTemplateView()
public ErrorTemplateView(@Nullable
java.lang.String templatePath)
public ErrorTemplateView(@Nullable
java.lang.String templatePath,
@Nullable
java.nio.charset.Charset charset)
public javax.ws.rs.WebApplicationException getError()
ServerPagesBundle.AppBuilder.errorPage(int, String)).
For all other cases (from error pages) method is useless.public int getErrorCode()
getError().getResponse().getStatus(). Shortcut created because direct expression
can't be used in freemarker expression.getError()public java.lang.String getErrorTrace()
Note that in case of direct error code return (404, 500 etc) exception will be "empty" (exception instance will be created but not thrown).
getError()public java.lang.String getErroredUrl()
request.getRequestURI()).