Example usage for org.springframework.core.convert ConversionFailedException printStackTrace

List of usage examples for org.springframework.core.convert ConversionFailedException printStackTrace

Introduction

In this page you can find the example usage for org.springframework.core.convert ConversionFailedException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.oncoblocks.centromere.web.controller.RequestUtils.java

/**
 * Converts an object into the appropriate type defined by the model field being queried.
 *
 * @param param// w  w w .  ja  v  a2  s.  co m
 * @param type
 * @return
 */
public static Object convertParameter(Object param, Class<?> type, ConversionService conversionService) {
    logger.debug(String.format("Attempting to convert parameter: from=%s to=%s", param.getClass().getName(),
            type.getName()));
    if (conversionService.canConvert(param.getClass(), type)) {
        try {
            return conversionService.convert(param, type);
        } catch (ConversionFailedException e) {
            e.printStackTrace();
            throw new InvalidParameterException("Unable to convert String to " + type.getName());
        }
    } else {
        return param;
    }
}