From: Jussi Koskela Date: Fri, 9 Dec 2016 13:55:00 +0000 (+0200) Subject: ValueConversion.parsePrimitive consumes NumberFormatException silently X-Git-Tag: v1.25.0~12^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F95%2F195%2F1;p=simantics%2Fplatform.git ValueConversion.parsePrimitive consumes NumberFormatException silently Don't catch the exception since we want to be aware of the problem at top level. refs #6863 Change-Id: I4b09a0e705b2e6fdd62c3b59bc70e5c188abb59f --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/ValueConversion.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/ValueConversion.java index 049799566..b9b4a3711 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/ValueConversion.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/ValueConversion.java @@ -45,33 +45,29 @@ public class ValueConversion { } public static Object parsePrimitive(TCon expectedType, String value) { - try { - if (expectedType == Types.DOUBLE) { - return Double.parseDouble(value); - } - else if (expectedType == Types.INTEGER) { - return Integer.parseInt(value); - } - else if (expectedType == Types.FLOAT) { - return Float.parseFloat(value); - } - else if (expectedType == Types.BYTE) { - return Byte.parseByte(value); - } - else if (expectedType == Types.SHORT) { - return Short.parseShort(value); - } - else if (expectedType == Types.LONG) { - return Long.parseLong(value); - } - else if (expectedType == Types.BOOLEAN) { - return Boolean.parseBoolean(value); - } - else if (expectedType == Types.CHARACTER && value.length() == 1) { - return value.charAt(0); - } - } catch(NumberFormatException e) { - e.printStackTrace(); + if (expectedType == Types.DOUBLE) { + return Double.parseDouble(value); + } + else if (expectedType == Types.INTEGER) { + return Integer.parseInt(value); + } + else if (expectedType == Types.FLOAT) { + return Float.parseFloat(value); + } + else if (expectedType == Types.BYTE) { + return Byte.parseByte(value); + } + else if (expectedType == Types.SHORT) { + return Short.parseShort(value); + } + else if (expectedType == Types.LONG) { + return Long.parseLong(value); + } + else if (expectedType == Types.BOOLEAN) { + return Boolean.parseBoolean(value); + } + else if (expectedType == Types.CHARACTER && value.length() == 1) { + return value.charAt(0); } return value;