When calling myPOstMethod of RESTful app , I got error "400 bad request" with no response body
The method definition is
@PostMapping()
public MyResponseDTO myPostMethod(
@Parameter(description = "Paramdescription")
@PathVariable String tokenParam,
@RequestBody MyRequestDTO requestBody
)
{
//fill response ...
return new MyResponseDTO(datafilled);
}
MyRequestDTO has field definied as following
public class MyRequestDTO extends BaseDTO {
......
@Override
public ExpType getExpType() {
return super.getExpType();
}
}
public enum ExpType {
VALUE1,
VALUE2,
VALUE3
}
The error occurs when request value which is NOT contain in the Enum (for example VALUE5 )
I am using
@ControllerAdvice
public class GlobalControllerExceptionHandler extends ResponseEntityExceptionHandler
As proposed here I am using GlobalControllerExceptionHandler annotated with @ControllerAdvice
With method to catch all exceptions defined as following
@ExceptionHandler(Exception.class)
@ResponseBody
ResponseEntity<Object> handleGeneralException(HttpServletRequest request, Exception ex) {
.....
}
But seems that this method does not called
What should be correct handler definition for such case ? Thanks in advance