report missing variable type only for variables

Change-Id: I89b7cbb3a93249df959ec17691f5b67dbb2ffda6
Reviewed-on: https://asterix-gerrit.ics.uci.edu/975
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: Yingyi Bu <buyingyi@gmail.com>
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java
index c5ceb1a..3046321 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java
@@ -52,7 +52,12 @@
             case FUNCTION_CALL:
                 return getTypeForFunction((AbstractFunctionCallExpression) expr, env, metadataProvider);
             case VARIABLE:
-                return env.getVarType(((VariableReferenceExpression) expr).getVariableReference());
+                try {
+                    return env.getVarType(((VariableReferenceExpression) expr).getVariableReference());
+                } catch (Exception e) {
+                    throw new AlgebricksException("Could not resolve type for " + expr.toString() + ","
+                            + "please check whether the used variable has been defined!", e);
+                }
             default:
                 throw new IllegalStateException();
         }
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/AbstractTypeEnvironment.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/AbstractTypeEnvironment.java
index 60d0740..c4ff55b 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/AbstractTypeEnvironment.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/AbstractTypeEnvironment.java
@@ -42,12 +42,7 @@
 
     @Override
     public Object getType(ILogicalExpression expr) throws AlgebricksException {
-        try {
-            return expressionTypeComputer.getType(expr, metadataProvider, this);
-        } catch (Exception e) {
-            throw new AlgebricksException("Could not resolve type for " + expr.toString() + ","
-                    + "please check whether the used variables has been defined!", e);
-        }
+        return expressionTypeComputer.getType(expr, metadataProvider, this);
     }
 
     @Override