Tests for ErrorResponse hierarchy to verify the output

See gh-27052
This commit is contained in:
rstoyanchev
2022-02-28 11:20:07 +00:00
parent 679432ece6
commit b045e5baef
20 changed files with 400 additions and 42 deletions

View File

@@ -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;
}
}

View File

@@ -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);
}
}