]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
ValueConversion.parsePrimitive consumes NumberFormatException silently 95/195/1
authorJussi Koskela <jussi.koskela@semantum.fi>
Fri, 9 Dec 2016 13:55:00 +0000 (15:55 +0200)
committerJussi Koskela <jussi.koskela@semantum.fi>
Fri, 9 Dec 2016 13:55:00 +0000 (15:55 +0200)
Don't catch the exception since we want to be aware of the problem at
top level.

refs #6863

Change-Id: I4b09a0e705b2e6fdd62c3b59bc70e5c188abb59f

bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/runtime/ValueConversion.java

index 049799566818015cb8359d9e5bcd0714267811ce..b9b4a3711a82c9f5dd503f22d057dafb8a47e428 100644 (file)
@@ -45,33 +45,29 @@ public class ValueConversion {
        }\r
        \r
        public static Object parsePrimitive(TCon expectedType, String value) {\r
-               try {\r
-                       if (expectedType == Types.DOUBLE) {\r
-                               return Double.parseDouble(value);\r
-                       }\r
-                       else if (expectedType == Types.INTEGER) {\r
-                               return Integer.parseInt(value);\r
-                       }\r
-                       else if (expectedType == Types.FLOAT) {\r
-                               return Float.parseFloat(value);\r
-                       }\r
-                       else if (expectedType == Types.BYTE) {\r
-                               return Byte.parseByte(value);\r
-                       }\r
-                       else if (expectedType == Types.SHORT) {\r
-                               return Short.parseShort(value);\r
-                       }\r
-                       else if (expectedType == Types.LONG) {\r
-                               return Long.parseLong(value);\r
-                       }\r
-                       else if (expectedType == Types.BOOLEAN) {\r
-                               return Boolean.parseBoolean(value);\r
-                       }\r
-                       else if (expectedType == Types.CHARACTER && value.length() == 1) {\r
-                               return value.charAt(0);\r
-                       }\r
-               } catch(NumberFormatException e) {\r
-                       e.printStackTrace();\r
+               if (expectedType == Types.DOUBLE) {\r
+                       return Double.parseDouble(value);\r
+               }\r
+               else if (expectedType == Types.INTEGER) {\r
+                       return Integer.parseInt(value);\r
+               }\r
+               else if (expectedType == Types.FLOAT) {\r
+                       return Float.parseFloat(value);\r
+               }\r
+               else if (expectedType == Types.BYTE) {\r
+                       return Byte.parseByte(value);\r
+               }\r
+               else if (expectedType == Types.SHORT) {\r
+                       return Short.parseShort(value);\r
+               }\r
+               else if (expectedType == Types.LONG) {\r
+                       return Long.parseLong(value);\r
+               }\r
+               else if (expectedType == Types.BOOLEAN) {\r
+                       return Boolean.parseBoolean(value);\r
+               }\r
+               else if (expectedType == Types.CHARACTER && value.length() == 1) {\r
+                       return value.charAt(0);\r
                }\r
                \r
                return value;\r