Fixed issue 142.
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization@593 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 15b959e..cf2b54c 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
@@ -98,16 +98,17 @@
out.println("</PRE>");
}
} catch (ParseException pe) {
- String message = pe.getMessage();
- message = message.replace("<", "<");
- message = message.replace(">", ">");
- int pos = message.indexOf("line");
- 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("SyntaxError:" + message);
- out.println("==> " + line);
-
+ String message = pe.getMessage();
+ message = message.replace("<", "<");
+ message = message.replace(">", ">");
+ out.println("SyntaxError:" + message);
+ int pos = message.indexOf("line");
+ 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);
+ }
} catch (Exception e) {
out.println(e.getMessage());
}