Server#setErrorHandler(Request.Handler) .
It is called by the Response#writeError(Request, Response, Callback, int, String)
to generate an error page.
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| private static class | ErrorHandler.
The callback used by
|
| Modifier and Type | Field and Description |
|---|---|
| pack-priv HttpField | |
| pack-priv boolean | |
| pack-priv boolean | |
| public static final HttpField | |
| public static final String | |
| public static final String | |
| public static final String | |
| public static final Set | |
| public static final String | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public ByteBuffer | Returns: The content as a ByteBuffer, or null for no body.The error code that will be sent status, String The reason for the error code (may be null) reason, HttpFields.The header fields that will be sent with the response. fieldsBad Message Error body Generate an error response body to be sent for a bad message. |
| public boolean | |
| protected boolean | |
| protected void | |
| public String | |
| public static Request. | |
| public boolean | handle(Request
the HTTP request to handle request, Response the HTTP response to handle response, Callback the callback to complete when the handling is complete callback)Implements org. Invoked to handle the passed HTTP request and response. |
| private void | |
| public boolean | |
| public boolean | |
| public void | setCacheControl(String
the cacheControl header to set on error responses. cacheControl)Set the cacheControl. |
| public void | setShowMessageInTitle(boolean
if true, the error message appears in page title showMessageInTitle)Set if true, the error message appears in page title. |
| public void | |
| protected void | |
| protected void | |
| protected void | writeErrorHtmlBody(Request request, Writer writer, int code, String message, Throwable cause, boolean showStacks)
|
| protected void | |
| protected void | |
| protected void | |
| protected void | |
| protected void | writeErrorJson(Request request, PrintWriter writer, int code, String message, Throwable cause, boolean showStacks)
|
| protected void | writeErrorPlain(Request request, PrintWriter writer, int code, String message, Throwable cause, boolean showStacks)
|
| _cacheControl | back to summary |
|---|---|
| pack-priv HttpField _cacheControl | |
| _showMessageInTitle | back to summary |
|---|---|
| pack-priv boolean _showMessageInTitle | |
| _showStacks | back to summary |
|---|---|
| pack-priv boolean _showStacks | |
| ERROR_CACHE_CONTROL | back to summary |
|---|---|
| public static final HttpField ERROR_CACHE_CONTROL | |
| ERROR_CONTEXT | back to summary |
|---|---|
| public static final String ERROR_CONTEXT | |
| ERROR_EXCEPTION | back to summary |
|---|---|
| public static final String ERROR_EXCEPTION | |
| ERROR_MESSAGE | back to summary |
|---|---|
| public static final String ERROR_MESSAGE | |
| ERROR_METHODS | back to summary |
|---|---|
| public static final Set<String> ERROR_METHODS | |
| ERROR_STATUS | back to summary |
|---|---|
| public static final String ERROR_STATUS | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| ErrorHandler | back to summary |
|---|---|
| public ErrorHandler() | |
| badMessageError | back to summary |
|---|---|
| public ByteBuffer badMessageError(int status, String reason, HttpFields. Bad Message Error body Generate an error response body to be sent for a bad message. In this case there is something wrong with the request, so either a request cannot be built, or it is not safe to build a request. This method allows for a simple error page body to be returned and some response headers to be set.
| |
| errorPageForMethod | back to summary |
|---|---|
| public boolean errorPageForMethod(String method) | |
| generateAcceptableResponse | back to summary |
|---|---|
| protected boolean generateAcceptableResponse(Request request, Response response, Callback callback, String contentType, List<Charset> charsets, int code, String message, Throwable cause) throws IOException | |
| generateResponse | back to summary |
|---|---|
| protected void generateResponse(Request request, Response response, int code, String message, Throwable cause, Callback callback) throws IOException | |
| getCacheControl | back to summary |
|---|---|
| public String getCacheControl() Get the cacheControl.
| |
| getErrorHandler | back to summary |
|---|---|
| public static Request. | |
| handle | back to summary |
|---|---|
| public boolean handle(Request request, Response response, Callback callback) throws Exception Implements org. Doc from org. Invoked to handle the passed HTTP request and response. The request is accepted by returning true, then handling must be concluded by completing the passed callback. The handling may be asynchronous, i.e. this method may return true and complete the given callback later, possibly from a different thread. If this method returns false, then the callback must not be invoked and any mutation on the response reversed. Exceptions thrown by this method may be subsequently handled by an error The simplest implementation is:
public boolean handle(Request request, Response response, Callback callback)
{
callback.succeeded();
return true;
}
A HelloWorld implementation is:
public boolean handle(Request request, Response response, Callback callback)
{
response.write(true, ByteBuffer.wrap("Hello World\n".getBytes(StandardCharsets.UTF_8)), callback);
return true;
}
| |
| htmlRow | back to summary |
|---|---|
| private void htmlRow(Writer writer, String tag, Object value) throws IOException | |
| isShowMessageInTitle | back to summary |
|---|---|
public boolean isShowMessageInTitle()
| |
| isShowStacks | back to summary |
|---|---|
public boolean isShowStacks()
| |
| setCacheControl | back to summary |
|---|---|
| public void setCacheControl(String cacheControl) Set the cacheControl.
| |
| setShowMessageInTitle | back to summary |
|---|---|
| public void setShowMessageInTitle(boolean showMessageInTitle) Set if true, the error message appears in page title.
| |
| setShowStacks | back to summary |
|---|---|
public void setShowStacks(boolean showStacks)
| |
| write | back to summary |
|---|---|
| protected void write(Writer writer, String string) throws IOException | |
| writeErrorHtml | back to summary |
|---|---|
| protected void writeErrorHtml(Request request, Writer writer, Charset charset, int code, String message, Throwable cause, boolean showStacks) throws IOException | |
| writeErrorHtmlBody | back to summary |
|---|---|
| protected void writeErrorHtmlBody(Request request, Writer writer, int code, String message, Throwable cause, boolean showStacks) throws IOException | |
| writeErrorHtmlHead | back to summary |
|---|---|
| protected void writeErrorHtmlHead(Request request, Writer writer, int code, String message) throws IOException | |
| writeErrorHtmlMessage | back to summary |
|---|---|
| protected void writeErrorHtmlMessage(Request request, Writer writer, int code, String message, Throwable cause, String uri) throws IOException | |
| writeErrorHtmlMeta | back to summary |
|---|---|
| protected void writeErrorHtmlMeta(Request request, Writer writer, Charset charset) throws IOException | |
| writeErrorHtmlStacks | back to summary |
|---|---|
| protected void writeErrorHtmlStacks(Request request, Writer writer) throws IOException | |
| writeErrorJson | back to summary |
|---|---|
| protected void writeErrorJson(Request request, PrintWriter writer, int code, String message, Throwable cause, boolean showStacks) | |
| writeErrorPlain | back to summary |
|---|---|
| protected void writeErrorPlain(Request request, PrintWriter writer, int code, String message, Throwable cause, boolean showStacks) | |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | demand(Runnable
the demand callback to invoke when there is a content chunk available. demandCallback)Overrides org. Implements org. Demands to invoke the given demand callback parameter when a chunk of content is available. |
| public Content. | read()
Overrides org. Implements org. Reads a chunk of content. |
| public String |
| ATTRIBUTES | back to summary |
|---|---|
| private static final Set<String> ATTRIBUTES | |
| ErrorRequest | back to summary |
|---|---|
| public ErrorRequest(Request request, int status, String message, Throwable cause) | |
| demand | back to summary |
|---|---|
| public void demand(Runnable demandCallback) Overrides org. Implements org. Doc from org. Demands to invoke the given demand callback parameter when a chunk of content is available. See how to use this method idiomatically. Implementations guarantee that calls to this method are safely reentrant so that
stack overflows are avoided in the case of mutual recursion between the execution of
the The demand callback may be invoked spuriously: a subsequent call to Calling this method establishes a pending demand, which is fulfilled when the demand callback is invoked. Calling this method when there is already a pending demand results in an
If the invocation of the demand callback throws an exception, then | |
| read | back to summary |
|---|---|
| public Content. Overrides org. Implements org. Doc from org. Reads a chunk of content. See how to use this method idiomatically. The returned chunk could be:
Once a read returns an Once a read returns a The content reader code must ultimately arrange for a call to
Additionally, prior to the ultimate call to Concurrent reads from different threads are not recommended, as they are inherently in a race condition. Reads performed outside the invocation context of a
In addition, the returned
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
ErrorHandler#generateAcceptableResponse(Request, Response, Callback, String, List, int, String, Throwable)
when calling Response#write(boolean, ByteBuffer, Callback) to wrap the passed in Callback
so that the RetainableByteBuffer used can be released.
| Modifier and Type | Field and Description |
|---|---|
| private final Retainable |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void |
| _retainable | back to summary |
|---|---|
| private final Retainable _retainable | |
| WriteErrorCallback | back to summary |
|---|---|
| public WriteErrorCallback(Callback callback, Retainable retainable) | |
| completed | back to summary |
|---|---|
| public void completed() Overrides org. Implements org.
| |