Display TokenMgrError messages too along with ParseException.

Also make some small CSS changes to make it clear that there was an error.

git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_api_cleanup@1498 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
index c4d32e1..12fa51a 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/APIServlet.java
@@ -6,6 +6,7 @@
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.util.List;
+import java.util.logging.Level;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServlet;
@@ -17,7 +18,9 @@
 import edu.uci.ics.asterix.aql.base.Statement;
 import edu.uci.ics.asterix.aql.parser.AQLParser;
 import edu.uci.ics.asterix.aql.parser.ParseException;
+import edu.uci.ics.asterix.aql.parser.TokenMgrError;
 import edu.uci.ics.asterix.aql.translator.AqlTranslator;
+import edu.uci.ics.asterix.common.config.GlobalConfig;
 import edu.uci.ics.asterix.metadata.MetadataManager;
 import edu.uci.ics.asterix.result.ResultReader;
 import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
@@ -76,7 +79,8 @@
             long endTime = System.currentTimeMillis();
             duration = (endTime - startTime) / 1000.00;
             out.println("<PRE>Duration of all jobs: " + duration + "</PRE>");
-        } catch (ParseException pe) {
+        } catch (ParseException | TokenMgrError | edu.uci.ics.asterix.aqlplus.parser.TokenMgrError pe) {
+            out.println("<pre class=\"error\">");
             String message = pe.getMessage();
             message = message.replace("<", "&lt");
             message = message.replace(">", "&gt");
@@ -85,12 +89,20 @@
             if (pos > 0) {
                 int columnPos = message.indexOf(",", pos + 1 + "line".length());
                 int lineNo = Integer.parseInt(message.substring(pos + "line".length() + 1, columnPos));
-                String line = query.split("\n")[lineNo - 1];
-                out.println("==> " + line);
+                String[] lines = query.split("\n");
+                if (lineNo >= lines.length) {
+                    out.println("===> &ltBLANK LINE&gt");
+                } else {
+                    String line = lines[lineNo - 1];
+                    out.println("==> " + line);
+                }
             }
+            out.println("</pre>");
         } catch (Exception e) {
-            e.printStackTrace();
+            GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, e.getMessage(), e);
+            out.println("<pre class=\"error\">");
             out.println(e.getMessage());
+            out.println("</pre>");
         }
     }
 
diff --git a/asterix-app/src/main/resources/webui/static/css/style.css b/asterix-app/src/main/resources/webui/static/css/style.css
index 10f28dd..b8688db 100644
--- a/asterix-app/src/main/resources/webui/static/css/style.css
+++ b/asterix-app/src/main/resources/webui/static/css/style.css
@@ -84,15 +84,7 @@
     resize: none;
 }
 
-div.error label.heading {
-    color: #ff2020;
-    font-size: 24px;
-    margin-top: 2px;
-    padding-bottom: 10px;
-    font-weight: bold;
-}
-
-div.error .message {
+div.output .message pre.error {
     -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
     -ms-box-sizing: border-box;