Example usage for org.springframework.beans PropertyAccessException getMostSpecificCause

List of usage examples for org.springframework.beans PropertyAccessException getMostSpecificCause

Introduction

In this page you can find the example usage for org.springframework.beans PropertyAccessException getMostSpecificCause.

Prototype

public Throwable getMostSpecificCause() 

Source Link

Document

Retrieve the most specific cause of this exception, that is, either the innermost cause (root cause) or this exception itself.

Usage

From source file:net.solarnetwork.node.power.modbus.ModbusPowerDatumDataSource.java

private void setRegisterAddressValue(final PropertyAccessor bean, final Integer addr, final String propertyName,
        final Integer propertyValue) {
    if (bean.isWritableProperty(propertyName)) {
        Number value = propertyValue;
        if (registerScaleFactor != null && registerScaleFactor.containsKey(addr)) {
            value = Double.valueOf(value.intValue() * registerScaleFactor.get(addr));
        }// ww w  .  j av a2s  . c om
        log.trace("Setting property {} for address 0x{} to [{}]", propertyName, Integer.toHexString(addr),
                value);
        try {
            bean.setPropertyValue(propertyName, value);
        } catch (PropertyAccessException e) {
            log.warn("Unable to set property {} to {} for address 0x{}: {}", propertyName, value,
                    Integer.toHexString(addr), e.getMostSpecificCause().getMessage());
        }
    } else {
        log.warn("Property {} not available; bad configuration", propertyName);
    }
}