Fix getting error code from attributes in our custom GlobalErrorWebExceptionHandler

This commit is contained in:
Ildar Almakaev 2021-02-11 11:44:15 +03:00
parent 7776301cee
commit 24e5d4dc5c

View file

@ -38,7 +38,7 @@ public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHan
private Mono<ServerResponse> renderErrorResponse(ServerRequest request) {
Map<String, Object> errorAttributes = getErrorAttributes(request, false);
HttpStatus statusCode = Optional.ofNullable(errorAttributes.get(GlobalErrorAttributes.STATUS))
.map(code -> (HttpStatus) code)
.map(code -> code instanceof Integer ? HttpStatus.valueOf((Integer) code) : (HttpStatus) code)
.orElse(HttpStatus.BAD_REQUEST);
return ServerResponse
.status(statusCode)