mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge branch '2.4.x'
Closes gh-25785
This commit is contained in:
commit
38584f0694
@ -54,9 +54,9 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
import org.springframework.web.servlet.handler.MatchableHandlerMapping;
|
||||
import org.springframework.web.servlet.handler.RequestMatchResult;
|
||||
@ -291,7 +291,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
||||
return handleResult(this.operation.invoke(invocationContext), HttpMethod.resolve(request.getMethod()));
|
||||
}
|
||||
catch (InvalidEndpointRequestException ex) {
|
||||
throw new BadOperationRequestException(ex.getReason());
|
||||
throw new InvalidEndpointBadRequestException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -404,11 +404,14 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
||||
|
||||
}
|
||||
|
||||
@ResponseStatus(code = HttpStatus.BAD_REQUEST)
|
||||
private static class BadOperationRequestException extends RuntimeException {
|
||||
/**
|
||||
* Nested exception used to wrap a {@link InvalidEndpointRequestException} and provide
|
||||
* a {@link HttpStatus#BAD_REQUEST} status.
|
||||
*/
|
||||
private static class InvalidEndpointBadRequestException extends ResponseStatusException {
|
||||
|
||||
BadOperationRequestException(String message) {
|
||||
super(message);
|
||||
InvalidEndpointBadRequestException(InvalidEndpointRequestException cause) {
|
||||
super(HttpStatus.BAD_REQUEST, cause.getReason(), cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user