Package play.http
Class PreferredMediaTypeHttpErrorHandler
- Object
-
- play.http.PreferredMediaTypeHttpErrorHandler
-
- All Implemented Interfaces:
HttpErrorHandler
- Direct Known Subclasses:
HtmlOrJsonHttpErrorHandler
public class PreferredMediaTypeHttpErrorHandler extends Object implements HttpErrorHandler
An `HttpErrorHandler` that delegates to one of several `HttpErrorHandlers` depending on the client's media type preference. The order of preference is defined by the client's `Accept` header. The handlers are specified as a `LinkedHashMap`, and the ordering of the map determines the order in which media types are chosen when they are equally preferred by a specific media range (e.g. `*\/*`).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface play.http.HttpErrorHandler
HttpErrorHandler.Attrs
-
-
Constructor Summary
Constructors Constructor Description PreferredMediaTypeHttpErrorHandler(LinkedHashMap<String,HttpErrorHandler> errorHandlerMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Result>
onClientError(Http.RequestHeader request, int statusCode, String message)
Invoked when a client error occurs, that is, an error in the 4xx series.CompletionStage<Result>
onServerError(Http.RequestHeader request, Throwable exception)
Invoked when a server error occurs.protected HttpErrorHandler
preferred(Http.RequestHeader request)
-
-
-
Constructor Detail
-
PreferredMediaTypeHttpErrorHandler
public PreferredMediaTypeHttpErrorHandler(LinkedHashMap<String,HttpErrorHandler> errorHandlerMap)
-
-
Method Detail
-
preferred
protected HttpErrorHandler preferred(Http.RequestHeader request)
-
onClientError
public CompletionStage<Result> onClientError(Http.RequestHeader request, int statusCode, String message)
Description copied from interface:HttpErrorHandler
Invoked when a client error occurs, that is, an error in the 4xx series.- Specified by:
onClientError
in interfaceHttpErrorHandler
- Parameters:
request
- The request that caused the client error.statusCode
- The error status code. Must be greater or equal to 400, and less than 500.message
- The error message.- Returns:
- a CompletionStage with the Result.
-
onServerError
public CompletionStage<Result> onServerError(Http.RequestHeader request, Throwable exception)
Description copied from interface:HttpErrorHandler
Invoked when a server error occurs.- Specified by:
onServerError
in interfaceHttpErrorHandler
- Parameters:
request
- The request that triggered the server error.exception
- The server error.- Returns:
- a CompletionStage with the Result.
-
-