@ExceptionHandler(MethodArgumentTypeMismatchException.class) public static ResponseEntity<?> handleMethodArgumentTypeMismatchException( final MethodArgumentTypeMismatchException exception) { final Throwable cause = exception.getCause(); if (cause instanceof ConversionFailedException) { return handleConversionFailedException((ConversionFailedException) cause); } else { return sendError(HttpStatus.BAD_REQUEST, exception.getMessage()); } }
@ExceptionHandler({MethodArgumentTypeMismatchException.class}) public void badArguments(HttpServletResponse res, MethodArgumentTypeMismatchException e) throws IOException { res.sendError(BAD_REQUEST.value(), String.format(MSG_TEMPLATE, e.getName(), e.getValue())); }