1
1
mirror of https://github.com/MarginaliaSearch/MarginaliaSearch.git synced 2025-10-05 21:22:39 +02:00

(math) Reduce log error spam from null unit conversions

This commit is contained in:
Viktor Lofgren
2024-12-21 18:51:45 +01:00
parent 1118657ffd
commit 5ca8523220

View File

@@ -49,13 +49,14 @@ public class Units {
var fromUnit = unitsByName.get(fromUnitName.toLowerCase());
var toUnit = unitsByName.get(toUnitName.toLowerCase());
if (Objects.equals(fromUnit, toUnit)) {
return Optional.of(value + " " + fromUnit.name);
}
if (null == fromUnit || null == toUnit) {
return Optional.empty();
}
if (Objects.equals(fromUnit, toUnit)) {
return Optional.of(value + " " + fromUnit.name);
}
if (!Objects.equals(toUnit.type, fromUnit.type)) {
return Optional.empty();
}