Tests for ErrorResponse hierarchy to verify the output
See gh-27052
This commit is contained in:
@@ -45,7 +45,7 @@ public class NoHandlerFoundException extends ServletException implements ErrorRe
|
||||
|
||||
private final HttpHeaders headers;
|
||||
|
||||
private final ProblemDetail detail = ProblemDetail.forRawStatusCode(getRawStatusCode());
|
||||
private final ProblemDetail body;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,10 +55,11 @@ public class NoHandlerFoundException extends ServletException implements ErrorRe
|
||||
* @param headers the HTTP request headers
|
||||
*/
|
||||
public NoHandlerFoundException(String httpMethod, String requestURL, HttpHeaders headers) {
|
||||
super("No handler found for " + httpMethod + " " + requestURL);
|
||||
super("No endpoint " + httpMethod + " " + requestURL + ".");
|
||||
this.httpMethod = httpMethod;
|
||||
this.requestURL = requestURL;
|
||||
this.headers = headers;
|
||||
this.body = ProblemDetail.forRawStatusCode(getRawStatusCode()).withDetail(getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +82,7 @@ public class NoHandlerFoundException extends ServletException implements ErrorRe
|
||||
|
||||
@Override
|
||||
public ProblemDetail getBody() {
|
||||
return this.detail;
|
||||
return this.body;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -154,6 +154,7 @@ public abstract class ResponseEntityExceptionHandler {
|
||||
return handleAsyncRequestTimeoutException(subEx, subEx.getHeaders(), subEx.getStatus(), request);
|
||||
}
|
||||
else {
|
||||
// Another ErrorResponseException
|
||||
return handleExceptionInternal(ex, null, errorEx.getHeaders(), errorEx.getStatus(), request);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user