mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
Fix build and improve exception handling (#10726)
The PercentType and QuantityType can also throw an IllegalArgumentException. Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
b049d3d13b
commit
a032118213
@ -92,7 +92,7 @@ public class DimmerItemConverter extends AbstractTransformingItemConverter {
|
||||
value = PercentType.ZERO.toBigDecimal();
|
||||
}
|
||||
newState = new PercentType(value);
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ package org.openhab.binding.http.internal.converter;
|
||||
|
||||
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;
|
||||
@ -62,7 +60,7 @@ public class NumberItemConverter extends AbstractTransformingItemConverter {
|
||||
return new QuantityType<>(trimmedValue);
|
||||
}
|
||||
}
|
||||
} catch (IllegalArgumentException | MeasurementParseException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
// finally failed
|
||||
}
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ public class IAqualinkHandler extends BaseThingHandler {
|
||||
default:
|
||||
return StringType.valueOf(value);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UnDefType.UNDEF;
|
||||
}
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ import org.slf4j.LoggerFactory;
|
||||
@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);
|
||||
|
@ -159,8 +159,8 @@ public class WLedHandler extends BaseThingHandler {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ public class NeeoItemValueConverter {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
// do nothing - let it go to the other cases
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class ScaleTransformationService extends AbstractFileTransformationServic
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user