improve error messages

Change-Id: Ia82cd34ae5099f924302d7d42b541247a258c9b9
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1225
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
index a244a74..0a45cdf 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -6263,7 +6263,7 @@
     <test-case FilePath="user-defined-functions">
       <compilation-unit name="query-issue455">
         <output-dir compare="Text">query-issue455</output-dir>
-        <expected-error>Error: function test.printName@0 is undefined</expected-error>
+        <expected-error>Error: function test.printName@0 is not defined</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="user-defined-functions">
@@ -6439,7 +6439,7 @@
     <test-case FilePath="user-defined-functions">
       <compilation-unit name="f01">
         <output-dir compare="Text">f01</output-dir>
-        <expected-error>Error: function test.int8@0 is undefined</expected-error>
+        <expected-error>Error: function test.int8@0 is not defined</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="user-defined-functions">
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index 2838f1f..5dd0bd0 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -7040,7 +7040,7 @@
     <test-case FilePath="user-defined-functions">
       <compilation-unit name="query-issue455">
         <output-dir compare="Text">query-issue455</output-dir>
-        <expected-error>function test.printName@0 is undefined</expected-error>
+        <expected-error>function test.printName@0 is not defined</expected-error>
       </compilation-unit>
     </test-case>
     <test-case FilePath="user-defined-functions">
@@ -7212,7 +7212,7 @@
     <test-case FilePath="user-defined-functions">
       <compilation-unit name="f01">
         <output-dir compare="Text">f01</output-dir>
-        <expected-error>function test.tinyint@0 is undefined</expected-error>
+        <expected-error>function test.tinyint@0 is not defined</expected-error>
       </compilation-unit>
     </test-case>
     <!-- This test case is not valid anymore since we do not required "IMPORT_PRIVATE_FUNCTIONS" flag anymore -->
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
index 1296955..5fee98c 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp_parser.xml
@@ -1143,6 +1143,12 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="constructor">
+      <compilation-unit name="int_02">
+        <expected-error>Syntax error: Could not parse numeric literal</expected-error>
+        <output-dir compare="AST">int_01</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="constructor">
       <compilation-unit name="interval">
         <output-dir compare="AST">interval</output-dir>
       </compilation-unit>
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
index 94866eb..2bc78a1 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
@@ -116,7 +116,7 @@
                     messageBuilder.append("function " + functionDecls.get(functionDecls.size() - 1).getSignature()
                             + " depends upon function " + signature + " which is undefined");
                 } else {
-                    messageBuilder.append("function " + signature + " is undefined ");
+                    messageBuilder.append("function " + signature + " is not defined");
                 }
                 throw new AsterixException(messageBuilder.toString());
             }
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index 697439d..f330f40 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -2187,15 +2187,27 @@
     }
   | <INTEGER_LITERAL>
     {
-      lit.setValue(new LongIntegerLiteral(new Long(token.image)));
+        try {
+            lit.setValue(new LongIntegerLiteral(Long.valueOf(token.image)));
+        } catch (NumberFormatException e) {
+            throw new ParseException("Could not parse numeric literal \"" + token.image +'"');
+        }
     }
   | <FLOAT_LITERAL>
     {
-      lit.setValue(new FloatLiteral(new Float(token.image)));
+        try {
+            lit.setValue(new FloatLiteral(Float.valueOf(token.image)));
+        } catch (NumberFormatException e) {
+            throw new ParseException("Could not parse numeric literal \"" + token.image +'"');
+        }
     }
   | <DOUBLE_LITERAL>
     {
-      lit.setValue(new DoubleLiteral(new Double(token.image)));
+        try {
+            lit.setValue(new DoubleLiteral(Double.valueOf(token.image)));
+        } catch (NumberFormatException e) {
+            throw new ParseException("Could not parse numeric literal \"" + token.image +'"');
+        }
     }
   | <MISSING>
     {