The PercentType and QuantityType can also throw an IllegalArgumentException.
Signed-off-by: Wouter Born <github@maindrain.net>
value = PercentType.ZERO.toBigDecimal();
}
newState = new PercentType(value);
- } catch (NumberFormatException e) {
+ } catch (IllegalArgumentException e) {
// ignore
}
}
import java.util.function.Consumer;
-import javax.measure.format.MeasurementParseException;
-
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.http.internal.config.HttpChannelConfig;
return new QuantityType<>(trimmedValue);
}
}
- } catch (IllegalArgumentException | MeasurementParseException e) {
+ } catch (IllegalArgumentException e) {
// finally failed
}
}
default:
return StringType.valueOf(value);
}
- } catch (NumberFormatException e) {
+ } catch (IllegalArgumentException e) {
return UnDefType.UNDEF;
}
}
@NonNullByDefault
public class CommandTag {
- private static final List<Class<? extends Command>> otherCommandTypes = Arrays.asList(DecimalType.class,
- QuantityType.class, OnOffType.class, OpenClosedType.class, UpDownType.class, HSBType.class,
+ private static final List<Class<? extends Command>> otherCommandTypes = Arrays.asList(HSBType.class,
+ DecimalType.class, QuantityType.class, OnOffType.class, OpenClosedType.class, UpDownType.class,
PlayPauseType.class, RewindFastforwardType.class, StringType.class);
private static final List<Class<? extends Command>> percentCommandType = Arrays.asList(PercentType.class);
updateState(CHANNEL_SECONDARY_WHITE,
new PercentType(secondaryWhite.divide(BIG_DECIMAL_2_55, RoundingMode.HALF_UP)));
}
- } catch (NumberFormatException e) {
- logger.warn("NumberFormatException when parsing the WLED colour and white fields:{}", e.getMessage());
+ } catch (IllegalArgumentException e) {
+ logger.warn("IllegalArgumentException when parsing the WLED colour and white fields:{}", e.getMessage());
}
}
default:
break;
}
- } catch (NumberFormatException e) {
+ } catch (IllegalArgumentException e) {
// do nothing - let it go to the other cases
}
}
try {
final QuantityType<?> quantity = new QuantityType<>(source);
return formatResult(data, source, quantity.toBigDecimal());
- } catch (NumberFormatException e2) {
+ } catch (IllegalArgumentException e2) {
String nonNumeric = data.get(null);
if (nonNumeric != null) {
return nonNumeric;