public class SpringMvcWebErrorHandler extends Object implements WebErrorHandler
WebErrorHandler implementation responsible for handling common Spring MVC
specific exceptions.| Modifier and Type | Field and Description |
|---|---|
static String |
INVALID_OR_MISSING_BODY
When we couldn't process the request body.
|
static String |
METHOD_NOT_ALLOWED
The HTTP method not supported on the resource.
|
static String |
MISSING_PARAMETER
When a required request parameter is missing.
|
static String |
MISSING_PART
When a required request part is missing.
|
static String |
NO_HANDLER
When we couldn't find any controller to handle the request.
|
static String |
NOT_ACCEPTABLE
When the
Accept header is invalid. |
static String |
NOT_SUPPORTED
When the
Content-Type header is not supported. |
| Constructor and Description |
|---|
SpringMvcWebErrorHandler() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canHandle(Throwable exception)
Only handles
ServletExceptions and HttpMessageNotReadableExceptions. |
HandledException |
handle(Throwable exception)
Bunch of if-else-es to return an appropriate
HandledException based on the
nature of the given exception. |
public static final String INVALID_OR_MISSING_BODY
public static final String NOT_ACCEPTABLE
Accept header is invalid.public static final String NOT_SUPPORTED
Content-Type header is not supported.public static final String METHOD_NOT_ALLOWED
public static final String MISSING_PARAMETER
public static final String MISSING_PART
public static final String NO_HANDLER
public boolean canHandle(Throwable exception)
ServletExceptions and HttpMessageNotReadableExceptions.canHandle in interface WebErrorHandlerexception - The exception to examine.true when can handle the exception, false otherwise.@NonNull public HandledException handle(Throwable exception)
HandledException based on the
nature of the given exception.
I've never wanted Switch Expressions and Pattern Matching more!
handle in interface WebErrorHandlerexception - The exception to handle.HandledException to the given exception.Copyright © 2018. All rights reserved.