Java Code Examples for org.springframework.web.method.annotation.MethodArgumentTypeMismatchException

The following examples show how to use org.springframework.web.method.annotation.MethodArgumentTypeMismatchException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Client did not formulate a correct request.
 * Log the exception message at warn level and stack trace as trace level.
 * Return response status HttpStatus.BAD_REQUEST (400).
 */
@ExceptionHandler({
	MissingServletRequestParameterException.class,
	MethodArgumentTypeMismatchException.class,
	InvalidStreamDefinitionException.class
})
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public VndErrors onClientGenericBadRequest(Exception e) {
	String logref = logWarnLevelExceptionMessage(e);
	if (logger.isTraceEnabled()) {
		logTraceLevelStrackTrace(e);
	}
	String msg = getExceptionMessage(e);
	return new VndErrors(logref, msg);
}
 
Example 2
public BaseExceptionHandler(final Logger log) {
    this.log = log;

    registerMapping(
            MissingServletRequestParameterException.class,
            "MISSING_PARAMETER",
            "Missing request parameter",
            BAD_REQUEST);
    registerMapping(
            MethodArgumentTypeMismatchException.class,
            "ARGUMENT_TYPE_MISMATCH",
            "Argument type mismatch",
            BAD_REQUEST);
    registerMapping(
            HttpRequestMethodNotSupportedException.class,
            "METHOD_NOT_SUPPORTED",
            "HTTP method not supported",
            METHOD_NOT_ALLOWED);
    registerMapping(
            ServletRequestBindingException.class,
            "MISSING_HEADER",
            "Missing header in request",
            BAD_REQUEST);
}
 
Example 3
Source Project: staffjoy   Source File: GlobalExceptionTranslator.java    License: MIT License 5 votes vote down vote up
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public BaseResponse handleError(MethodArgumentTypeMismatchException e) {
    logger.warn("Method Argument Type Mismatch", e);
    String message = String.format("Method Argument Type Mismatch: %s", e.getName());
    return BaseResponse
            .builder()
            .code(ResultCode.PARAM_TYPE_ERROR)
            .message(message)
            .build();
}
 
Example 4
Source Project: Blog   Source File: GlobalExceptionHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
     * controller参数异常/缺少
     *
     * @param e
     * @return
     */
    @ExceptionHandler({
            MissingServletRequestParameterException.class,
            MethodArgumentTypeMismatchException.class,
            RequestRejectedException.class}
    )
    public Result missingServletRequestParameterException(Exception e) {
//        e.printStackTrace();
        return Result.create(StatusCode.ERROR, "参数异常");

    }
 
Example 5
Source Project: spring-boot-demo   Source File: GlobalExceptionHandler.java    License: MIT License 5 votes vote down vote up
@ExceptionHandler(value = Exception.class)
@ResponseBody
public ApiResponse handlerException(Exception e) {
    if (e instanceof NoHandlerFoundException) {
        log.error("【全局异常拦截】NoHandlerFoundException: 请求方法 {}, 请求路径 {}", ((NoHandlerFoundException) e).getRequestURL(), ((NoHandlerFoundException) e).getHttpMethod());
        return ApiResponse.ofStatus(Status.REQUEST_NOT_FOUND);
    } else if (e instanceof HttpRequestMethodNotSupportedException) {
        log.error("【全局异常拦截】HttpRequestMethodNotSupportedException: 当前请求方式 {}, 支持请求方式 {}", ((HttpRequestMethodNotSupportedException) e).getMethod(), JSONUtil.toJsonStr(((HttpRequestMethodNotSupportedException) e).getSupportedHttpMethods()));
        return ApiResponse.ofStatus(Status.HTTP_BAD_METHOD);
    } else if (e instanceof MethodArgumentNotValidException) {
        log.error("【全局异常拦截】MethodArgumentNotValidException", e);
        return ApiResponse.of(Status.BAD_REQUEST.getCode(), ((MethodArgumentNotValidException) e).getBindingResult()
                .getAllErrors()
                .get(0)
                .getDefaultMessage(), null);
    } else if (e instanceof ConstraintViolationException) {
        log.error("【全局异常拦截】ConstraintViolationException", e);
        return ApiResponse.of(Status.BAD_REQUEST.getCode(), CollUtil.getFirst(((ConstraintViolationException) e).getConstraintViolations())
                .getMessage(), null);
    } else if (e instanceof MethodArgumentTypeMismatchException) {
        log.error("【全局异常拦截】MethodArgumentTypeMismatchException: 参数名 {}, 异常信息 {}", ((MethodArgumentTypeMismatchException) e).getName(), ((MethodArgumentTypeMismatchException) e).getMessage());
        return ApiResponse.ofStatus(Status.PARAM_NOT_MATCH);
    } else if (e instanceof HttpMessageNotReadableException) {
        log.error("【全局异常拦截】HttpMessageNotReadableException: 错误信息 {}", ((HttpMessageNotReadableException) e).getMessage());
        return ApiResponse.ofStatus(Status.PARAM_NOT_NULL);
    } else if (e instanceof BadCredentialsException) {
        log.error("【全局异常拦截】BadCredentialsException: 错误信息 {}", e.getMessage());
        return ApiResponse.ofStatus(Status.USERNAME_PASSWORD_ERROR);
    } else if (e instanceof DisabledException) {
        log.error("【全局异常拦截】BadCredentialsException: 错误信息 {}", e.getMessage());
        return ApiResponse.ofStatus(Status.USER_DISABLED);
    } else if (e instanceof BaseException) {
        log.error("【全局异常拦截】DataManagerException: 状态码 {}, 异常信息 {}", ((BaseException) e).getCode(), e.getMessage());
        return ApiResponse.ofException((BaseException) e);
    }

    log.error("【全局异常拦截】: 异常信息 {} ", e.getMessage());
    return ApiResponse.ofStatus(Status.ERROR);
}
 
Example 6
/**
 * Handle Exception, handle generic Exception.class
 *
 * @param ex the Exception
 * @return the ApiError object
 */
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
protected ResponseEntity<Object> handleMethodArgumentTypeMismatch(MethodArgumentTypeMismatchException ex,
                                                                  WebRequest request) {
	ApiError apiError = new ApiError(BAD_REQUEST);
	apiError.setMessage(String.format("The parameter '%s' of value '%s' could not be converted to type '%s'", ex.getName(), ex.getValue(), ex.getRequiredType().getSimpleName()));
	apiError.setDebugMessage(ex.getMessage());
	return buildResponseEntity(apiError);
}
 
Example 7
@ExceptionHandler({ MethodArgumentTypeMismatchException.class })
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<ExceptionResponse> resolveException(MethodArgumentTypeMismatchException ex) {
	String message = "Parameter '" + ex.getParameter().getParameterName() + "' must be '"
			+ Objects.requireNonNull(ex.getRequiredType()).getSimpleName() + "'";
	List<String> messages = new ArrayList<>(1);
	messages.add(message);
	return new ResponseEntity<>(new ExceptionResponse(messages, HttpStatus.BAD_REQUEST.getReasonPhrase(),
			HttpStatus.BAD_REQUEST.value()), HttpStatus.BAD_REQUEST);
}
 
Example 8
Source Project: cola-cloud   Source File: GlobalExceptionHandler.java    License: MIT License 5 votes vote down vote up
@ResponseBody
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseStatus(HttpStatus.OK)
public Result handleMethodArgumentTypeMismatchExceptionException(
        MethodArgumentTypeMismatchException e) {

    log.error(ErrorStatus.ILLEGAL_ARGUMENT_TYPE.getMessage() + ":" + e.getMessage());
    return failure(ErrorStatus.ILLEGAL_ARGUMENT_TYPE,e);
}
 
Example 9
@ExceptionHandler({MethodArgumentTypeMismatchException.class})
public @ResponseBody
StandResponse exception(MethodArgumentTypeMismatchException e, HttpServletResponse response) {
    logger.error("#######ERROR#######", e);
    StandResponse standResponse = new StandResponse();
    standResponse.setCode(StandResponse.ARGUMENT_TYPE_MISSMATCH);
    standResponse.setSuccess(false);
    standResponse.setMsg("参数类型不匹配:" + e.getName());
    return standResponse;
}
 
Example 10
Source Project: kakaopay-coupon   Source File: ErrorController.java    License: MIT License 5 votes vote down vote up
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseBody
public ErrorInfo handleArgumentTypeMismatch(HttpServletRequest req, Exception ex) {
    log.info("handleArgumentTypeMismatch - Argument type mismatch");
    return new ErrorInfo(req.getRequestURL().toString(), "Argument type mismatch", ARG_TYPE_MISMATCH);
}
 
Example 11
Source Project: spring-boot-demo   Source File: GlobalExceptionHandler.java    License: MIT License 5 votes vote down vote up
@ExceptionHandler(value = Exception.class)
@ResponseBody
public ApiResponse handlerException(Exception e) {
    if (e instanceof NoHandlerFoundException) {
        log.error("【全局异常拦截】NoHandlerFoundException: 请求方法 {}, 请求路径 {}", ((NoHandlerFoundException) e).getRequestURL(), ((NoHandlerFoundException) e).getHttpMethod());
        return ApiResponse.ofStatus(Status.REQUEST_NOT_FOUND);
    } else if (e instanceof HttpRequestMethodNotSupportedException) {
        log.error("【全局异常拦截】HttpRequestMethodNotSupportedException: 当前请求方式 {}, 支持请求方式 {}", ((HttpRequestMethodNotSupportedException) e).getMethod(), JSONUtil.toJsonStr(((HttpRequestMethodNotSupportedException) e).getSupportedHttpMethods()));
        return ApiResponse.ofStatus(Status.HTTP_BAD_METHOD);
    } else if (e instanceof MethodArgumentNotValidException) {
        log.error("【全局异常拦截】MethodArgumentNotValidException", e);
        return ApiResponse.of(Status.BAD_REQUEST.getCode(), ((MethodArgumentNotValidException) e).getBindingResult()
                .getAllErrors()
                .get(0)
                .getDefaultMessage(), null);
    } else if (e instanceof ConstraintViolationException) {
        log.error("【全局异常拦截】ConstraintViolationException", e);
        return ApiResponse.of(Status.BAD_REQUEST.getCode(), CollUtil.getFirst(((ConstraintViolationException) e).getConstraintViolations())
                .getMessage(), null);
    } else if (e instanceof MethodArgumentTypeMismatchException) {
        log.error("【全局异常拦截】MethodArgumentTypeMismatchException: 参数名 {}, 异常信息 {}", ((MethodArgumentTypeMismatchException) e).getName(), ((MethodArgumentTypeMismatchException) e).getMessage());
        return ApiResponse.ofStatus(Status.PARAM_NOT_MATCH);
    } else if (e instanceof HttpMessageNotReadableException) {
        log.error("【全局异常拦截】HttpMessageNotReadableException: 错误信息 {}", ((HttpMessageNotReadableException) e).getMessage());
        return ApiResponse.ofStatus(Status.PARAM_NOT_NULL);
    } else if (e instanceof BadCredentialsException) {
        log.error("【全局异常拦截】BadCredentialsException: 错误信息 {}", e.getMessage());
        return ApiResponse.ofStatus(Status.USERNAME_PASSWORD_ERROR);
    } else if (e instanceof DisabledException) {
        log.error("【全局异常拦截】BadCredentialsException: 错误信息 {}", e.getMessage());
        return ApiResponse.ofStatus(Status.USER_DISABLED);
    } else if (e instanceof BaseException) {
        log.error("【全局异常拦截】DataManagerException: 状态码 {}, 异常信息 {}", ((BaseException) e).getCode(), e.getMessage());
        return ApiResponse.ofException((BaseException) e);
    }

    log.error("【全局异常拦截】: 异常信息 {} ", e.getMessage());
    return ApiResponse.ofStatus(Status.ERROR);
}
 
Example 12
/**
 * Handle Exception, handle generic Exception.class
 *
 * @param ex the Exception
 * @return the ApiError object
 */
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
protected ResponseEntity<Object> handleMethodArgumentTypeMismatch(MethodArgumentTypeMismatchException ex,
                                                                  WebRequest request) {
    ApiError apiError = new ApiError(BAD_REQUEST);
    apiError.setMessage(String.format("The parameter '%s' of value '%s' could not be converted to type '%s'", ex.getName(), ex.getValue(), ex.getRequiredType().getSimpleName()));
    apiError.setDebugMessage(ex.getMessage());
    return buildResponseEntity(apiError);
}
 
Example 13
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public R handleError(MethodArgumentTypeMismatchException e) {
	log.warn("请求参数格式错误", e.getMessage());
	String message = String.format("请求参数格式错误: %s", e.getName());
	return R.fail(ResultCode.PARAM_TYPE_ERROR, message);
}
 
Example 14
/**
 * MethodArgumentTypeMismatchException : 方法参数类型异常
 *
 * @param e
 * @return
 */
@ExceptionHandler(value = MethodArgumentTypeMismatchException.class)
@ResponseBody
public Object methodArgumentTypeMismatchException(Throwable e) {
    log.error("url参数异常,请检查参数类型是否匹配!", e);
    if (RequestUtil.isAjax(RequestHolder.getRequest())) {
        return ResultUtil.error(ResponseStatus.INVALID_PARAMS);
    }
    return ResultUtil.forward("/error/500");
}
 
Example 15
/**
 * Handle Exception, handle generic Exception.class
 *
 * @param ex the Exception
 * @return the ApiError object
 */
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
protected ResponseEntity<Object> handleMethodArgumentTypeMismatch(MethodArgumentTypeMismatchException ex,
                                                                  WebRequest request) {
    ApiError apiError = new ApiError(BAD_REQUEST);
    apiError.setMessage(String.format("The parameter '%s' of value '%s' could not be converted to type '%s'", ex.getName(), ex.getValue(), ex.getRequiredType().getSimpleName()));
    apiError.setDebugMessage(ex.getMessage());
    return buildResponseEntity(apiError);
}
 
Example 16
Source Project: spring-boot-demo   Source File: GlobalExceptionHandler.java    License: MIT License 5 votes vote down vote up
@ExceptionHandler(value = Exception.class)
@ResponseBody
public ApiResponse handlerException(Exception e) {
    if (e instanceof NoHandlerFoundException) {
        log.error("【全局异常拦截】NoHandlerFoundException: 请求方法 {}, 请求路径 {}", ((NoHandlerFoundException) e).getRequestURL(), ((NoHandlerFoundException) e).getHttpMethod());
        return ApiResponse.ofStatus(Status.REQUEST_NOT_FOUND);
    } else if (e instanceof HttpRequestMethodNotSupportedException) {
        log.error("【全局异常拦截】HttpRequestMethodNotSupportedException: 当前请求方式 {}, 支持请求方式 {}", ((HttpRequestMethodNotSupportedException) e).getMethod(), JSONUtil.toJsonStr(((HttpRequestMethodNotSupportedException) e).getSupportedHttpMethods()));
        return ApiResponse.ofStatus(Status.HTTP_BAD_METHOD);
    } else if (e instanceof MethodArgumentNotValidException) {
        log.error("【全局异常拦截】MethodArgumentNotValidException", e);
        return ApiResponse.of(Status.BAD_REQUEST.getCode(), ((MethodArgumentNotValidException) e).getBindingResult()
                .getAllErrors()
                .get(0)
                .getDefaultMessage(), null);
    } else if (e instanceof ConstraintViolationException) {
        log.error("【全局异常拦截】ConstraintViolationException", e);
        return ApiResponse.of(Status.BAD_REQUEST.getCode(), CollUtil.getFirst(((ConstraintViolationException) e).getConstraintViolations())
                .getMessage(), null);
    } else if (e instanceof MethodArgumentTypeMismatchException) {
        log.error("【全局异常拦截】MethodArgumentTypeMismatchException: 参数名 {}, 异常信息 {}", ((MethodArgumentTypeMismatchException) e).getName(), ((MethodArgumentTypeMismatchException) e).getMessage());
        return ApiResponse.ofStatus(Status.PARAM_NOT_MATCH);
    } else if (e instanceof HttpMessageNotReadableException) {
        log.error("【全局异常拦截】HttpMessageNotReadableException: 错误信息 {}", ((HttpMessageNotReadableException) e).getMessage());
        return ApiResponse.ofStatus(Status.PARAM_NOT_NULL);
    } else if (e instanceof BadCredentialsException) {
        log.error("【全局异常拦截】BadCredentialsException: 错误信息 {}", e.getMessage());
        return ApiResponse.ofStatus(Status.USERNAME_PASSWORD_ERROR);
    } else if (e instanceof DisabledException) {
        log.error("【全局异常拦截】BadCredentialsException: 错误信息 {}", e.getMessage());
        return ApiResponse.ofStatus(Status.USER_DISABLED);
    } else if (e instanceof BaseException) {
        log.error("【全局异常拦截】DataManagerException: 状态码 {}, 异常信息 {}", ((BaseException) e).getCode(), e.getMessage());
        return ApiResponse.ofException((BaseException) e);
    }

    log.error("【全局异常拦截】: 异常信息 {} ", e.getMessage());
    return ApiResponse.ofStatus(Status.ERROR);
}
 
Example 17
Source Project: xxproject   Source File: CustomRestExceptionHandler.java    License: Apache License 2.0 5 votes vote down vote up
@ExceptionHandler({ MethodArgumentTypeMismatchException.class })
public ResponseEntity<Object> handleMethodArgumentTypeMismatch(final MethodArgumentTypeMismatchException ex, final WebRequest request) {
    logger.info(ex.getClass().getName());
    //
    final String error = ex.getName() + " should be of type " + ex.getRequiredType().getName();

    final ApiError apiError = new ApiError(HttpStatus.BAD_REQUEST, ex.getLocalizedMessage(), error);
    return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus());
}
 
Example 18
Source Project: spring-boot   Source File: RestExceptionHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Handle Exception, handle generic Exception.class
 *
 * @param ex the Exception
 * @return the ApiError object
 */
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
protected ResponseEntity<Object> handleMethodArgumentTypeMismatch(MethodArgumentTypeMismatchException ex,
                                                                  WebRequest request) {
    RestApiError apiError = new RestApiError(BAD_REQUEST);
    apiError.setMessage(String.format("The parameter '%s' of value '%s' could not be converted to type '%s'", ex.getName(), ex.getValue(), ex.getRequiredType().getSimpleName()));
    apiError.setDebugMessage(ex.getMessage());
    return buildResponseEntity(apiError);
}
 
Example 19
protected String extractPropertyName(TypeMismatchException tme) {
    if (tme instanceof MethodArgumentTypeMismatchException) {
        return ((MethodArgumentTypeMismatchException) tme).getName();
    }

    if (tme instanceof MethodArgumentConversionNotSupportedException) {
        return ((MethodArgumentConversionNotSupportedException) tme).getName();
    }

    return null;
}
 
Example 20
@Test
public void extractPropertyName_works_for_MethodArgumentTypeMismatchException() {
    // given
    MethodArgumentTypeMismatchException exMock = mock(MethodArgumentTypeMismatchException.class);
    String name = UUID.randomUUID().toString();
    doReturn(name).when(exMock).getName();

    // when
    String result = listener.extractPropertyName(exMock);

    // then
    assertThat(result).isEqualTo(name);
}
 
Example 21
public BaseExceptionHandler(final Logger log) {
    this.log = log;

    registerMapping(MissingServletRequestParameterException.class, "MISSING_PARAMETER", "Missing request parameter", BAD_REQUEST);
    registerMapping(MethodArgumentTypeMismatchException.class, "ARGUMENT_TYPE_MISMATCH", "Argument type mismatch", BAD_REQUEST);
    registerMapping(HttpRequestMethodNotSupportedException.class, "METHOD_NOT_SUPPORTED", "HTTP method not supported", METHOD_NOT_ALLOWED);
    registerMapping(ServletRequestBindingException.class, "MISSING_HEADER", "Missing header in request", BAD_REQUEST);
}
 
Example 22
Source Project: POC   Source File: RestExceptionHandler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Handle Exception, handle generic Exception.class.
 * @param ex the Exception
 * @return the ApiError object
 * @param request a {@link org.springframework.web.context.request.WebRequest} object.
 */
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
protected ResponseEntity<Object> handleMethodArgumentTypeMismatch(MethodArgumentTypeMismatchException ex,
		WebRequest request) {
	final ApiError apiError = new ApiError(HttpStatus.BAD_REQUEST);
	apiError.setMessage(String.format("The parameter '%s' of value '%s' could not be converted to type '%s'",
			ex.getName(), ex.getValue(), Objects.requireNonNull(ex.getRequiredType()).getSimpleName()));
	apiError.setDebugMessage(ex.getMessage());
	return buildResponseEntity(apiError);
}
 
Example 23
Source Project: studio   Source File: ExceptionHandlers.java    License: GNU General Public License v3.0 5 votes vote down vote up
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseBody handleMethodArgumentTypeMismatchException(HttpServletRequest request,
                                                              MethodArgumentTypeMismatchException e) {
    ApiResponse response = new ApiResponse(ApiResponse.INVALID_PARAMS);
    return handleExceptionInternal(request, e, response);
}
 
Example 24
Source Project: tutorials   Source File: CustomRestExceptionHandler.java    License: MIT License 5 votes vote down vote up
@ExceptionHandler({ MethodArgumentTypeMismatchException.class })
public ResponseEntity<Object> handleMethodArgumentTypeMismatch(final MethodArgumentTypeMismatchException ex, final WebRequest request) {
    logger.info(ex.getClass().getName());
    //
    final String error = ex.getName() + " should be of type " + ex.getRequiredType().getName();

    final ApiError apiError = new ApiError(HttpStatus.BAD_REQUEST, ex.getLocalizedMessage(), error);
    return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus());
}
 
Example 25
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseBody
public Object badArgumentHandler(MethodArgumentTypeMismatchException e) {
    logger.error(e.getMessage(), e);
    return ResponseUtil.badArgumentValue();
}
 
Example 26
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseBody
public Object badArgumentHandler(MethodArgumentTypeMismatchException e) {
	e.printStackTrace();
	return ResponseUtil.badArgumentValue();
}
 
Example 27
Source Project: syhthems-platform   Source File: CustomExceptionHandler.java    License: MIT License 4 votes vote down vote up
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public ResultVO methodArgumentTypeMismatchExceptionHandler(final MethodArgumentTypeMismatchException e) {
    log.error("-----> Controller 参数异常:{}", e.getMessage());
    e.printStackTrace();
    return ResultUtils.error(ResultEnum.ILLEGAL_CONTROLLER_ARGUMENT);
}
 
Example 28
Source Project: mall   Source File: GlobalExceptionHandler.java    License: MIT License 4 votes vote down vote up
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseBody
public Object badArgumentHandler(MethodArgumentTypeMismatchException e) {
    e.printStackTrace();
    return ResponseUtil.badArgumentValue();
}
 
Example 29
Source Project: litemall   Source File: GlobalExceptionHandler.java    License: MIT License 4 votes vote down vote up
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseBody
public Object badArgumentHandler(MethodArgumentTypeMismatchException e) {
    logger.error(e.getMessage(), e);
    return ResponseUtil.badArgumentValue();
}
 
Example 30
private static String getPropertyName(TypeMismatchException mismatchException) {
    if (mismatchException instanceof MethodArgumentTypeMismatchException)
        return ((MethodArgumentTypeMismatchException) mismatchException).getName();

    return mismatchException.getPropertyName();
}