Search in sources :

Example 1 with UnknownParameterSetException

use of org.eclipse.smarthome.binding.homematic.internal.communicator.client.UnknownParameterSetException in project smarthome by eclipse.

the class RpcResponseParser method parse.

@Override
@SuppressWarnings("unchecked")
public Object[] parse(Object[] message) throws IOException {
    if (message != null && message.length > 0) {
        Object responseData = message[0];
        if (responseData instanceof Map) {
            Map<String, Object> map = (Map<String, Object>) responseData;
            if (map.containsKey("faultCode")) {
                Number faultCode = toNumber(map.get("faultCode"));
                String faultString = toString(map.get("faultString"));
                String faultMessage = String.format("%s %s (sending %s)", faultCode, faultString, request);
                if (faultCode.intValue() == -1 && StringUtils.equals("Failure", faultString)) {
                    throw new UnknownRpcFailureException(faultMessage);
                } else if (faultCode.intValue() == -3 && StringUtils.equals("Unknown paramset", faultString)) {
                    throw new UnknownParameterSetException(faultMessage);
                }
                throw new IOException(faultMessage);
            }
        }
        return message;
    }
    throw new IOException("Unknown Result: " + message);
}
Also used : UnknownParameterSetException(org.eclipse.smarthome.binding.homematic.internal.communicator.client.UnknownParameterSetException) IOException(java.io.IOException) Map(java.util.Map) UnknownRpcFailureException(org.eclipse.smarthome.binding.homematic.internal.communicator.client.UnknownRpcFailureException)

Aggregations

IOException (java.io.IOException)1 Map (java.util.Map)1 UnknownParameterSetException (org.eclipse.smarthome.binding.homematic.internal.communicator.client.UnknownParameterSetException)1 UnknownRpcFailureException (org.eclipse.smarthome.binding.homematic.internal.communicator.client.UnknownRpcFailureException)1