@RestController @ResponseBody @PreAuthorize(value="permitAll()") public class GatewayErrorController extends Object implements org.springframework.boot.autoconfigure.web.ErrorController
| Modifier and Type | Field and Description |
|---|---|
static String |
ATTR_ERROR_EXCEPTION |
static String |
ATTR_ERROR_MESSAGE |
static String |
ATTR_ERROR_STATUS_CODE |
static String |
ATTR_PROXY |
static String |
ATTR_SERVICE_ID |
static String |
ERROR_MESSAGE_GENERAL |
static String |
ERROR_MESSAGE_TIMEOUT |
static String |
ERROR_PATH |
static String |
ZUUL_REQUEST_URI |
| Constructor and Description |
|---|
GatewayErrorController() |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.http.ResponseEntity<?> |
error()
Error handling method that evalutes the current
RequestContext and extracts information on the request, matching routes and error
or exceptions that occurred during routing. |
protected org.springframework.http.ResponseEntity |
errorResponse(org.springframework.http.HttpStatus httpStatus,
String message,
String path)
Builds an
ResponseEntity containing a ErrorResponse body to return JSON error responses. |
protected com.netflix.zuul.context.RequestContext |
getCurrentContext() |
protected String |
getErrorMessageFromRequestContext(com.netflix.zuul.context.RequestContext requestContext) |
String |
getErrorPath() |
protected Exception |
getExceptionFromRequestContext(com.netflix.zuul.context.RequestContext requestContext) |
protected org.springframework.http.HttpStatus |
getHttpStatusFromRequestContext(com.netflix.zuul.context.RequestContext requestContext) |
protected String |
getRequestUriFromRequestContext(com.netflix.zuul.context.RequestContext requestContext) |
protected String |
getRouteFromRequestContext(com.netflix.zuul.context.RequestContext requestContext) |
protected String |
getServiceIdFromRequestContext(com.netflix.zuul.context.RequestContext requestContext) |
protected boolean |
isGatewayTimeout(Throwable throwable)
Checks if a given throwable matches any of the exception types that are expected to return a HTTP status code of 504 Gateway
Timeout.
|
protected boolean |
isServiceUnavailable(Throwable throwable)
Checks if a given throwable matches any of the exception types that are expected to return a HTTP status code of 503 Service
Unavailable.
|
public static final String ERROR_PATH
public static final String ATTR_ERROR_EXCEPTION
public static final String ATTR_ERROR_MESSAGE
public static final String ATTR_ERROR_STATUS_CODE
public static final String ATTR_PROXY
public static final String ATTR_SERVICE_ID
public static final String ZUUL_REQUEST_URI
public static final String ERROR_MESSAGE_GENERAL
public static final String ERROR_MESSAGE_TIMEOUT
@RequestMapping(value="/error") public org.springframework.http.ResponseEntity<?> error()
Error handling method that evalutes the current RequestContext and extracts information on the request, matching routes and error
or exceptions that occurred during routing.
It returns a ResponseEntity with an ErrorResponse body and one of these HTTP status codes, depending on the request
context information:
protected boolean isServiceUnavailable(Throwable throwable)
Checks if a given throwable matches any of the exception types that are expected to return a HTTP status code of 503 Service Unavailable.
In case of encountering exceptions that should return this response instead of 500 Internal Server Error, they need to be added to this method.
throwable - the exceptiontrue if it's an exception type that should result in a 503 Service Unavailable HTTP status responseprotected boolean isGatewayTimeout(Throwable throwable)
Checks if a given throwable matches any of the exception types that are expected to return a HTTP status code of 504 Gateway Timeout.
In case of encountering exceptions that should return this response instead of 500 Internal Server Error, they need to be added to this method.
throwable - the exceptiontrue if it's an exception type that should result in a 504 Gateway Timeout HTTP status responseprotected org.springframework.http.ResponseEntity errorResponse(org.springframework.http.HttpStatus httpStatus,
String message,
String path)
ResponseEntity containing a ErrorResponse body to return JSON error responses.httpStatus - the HTTP status code to returnmessage - the error messagepath - the request path where the error occurredprotected String getRequestUriFromRequestContext(com.netflix.zuul.context.RequestContext requestContext)
protected org.springframework.http.HttpStatus getHttpStatusFromRequestContext(com.netflix.zuul.context.RequestContext requestContext)
protected String getRouteFromRequestContext(com.netflix.zuul.context.RequestContext requestContext)
protected String getServiceIdFromRequestContext(com.netflix.zuul.context.RequestContext requestContext)
protected Exception getExceptionFromRequestContext(com.netflix.zuul.context.RequestContext requestContext)
protected String getErrorMessageFromRequestContext(com.netflix.zuul.context.RequestContext requestContext)
protected com.netflix.zuul.context.RequestContext getCurrentContext()
public String getErrorPath()
getErrorPath in interface org.springframework.boot.autoconfigure.web.ErrorControllerCopyright © 2015–2016 Smartrac Technology Fletcher, Inc.. All rights reserved.