From bed356d641e6ff953a2dcfaf04766f1e84191790 Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Fri, 9 Dec 2016 15:55:00 +0200 Subject: [PATCH] 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 --- .../scl/compiler/runtime/ValueConversion.java | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) 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; -- 2.47.1