Exception Interacting with ResultList in QueryHandler

7 views
Skip to first unread message

Philip Weaver

unread,
Apr 14, 2009, 8:28:04 PM4/14/09
to dovetaildb-discuss
I'm creating a queryHandler to delete properties from some results before they are returned. Seeing exception: org.mozilla.javascript.EvaluatorException: Constructor for "JavaException" not found

Also, is the Javascript delete operator going to work in this situation in Rhino? See "delete result.passcode" below.

function queryHandler(bag, query, options) {
_server.log('queryHandler');
if (bag == 'resources') {
var results = _server.inner.query(bag, query, options);
_server.log('results: ' + results);
try {
if (results != null) {
_server.log('results.size(): ' + results.size());
for (var i = 0; i < results.size(); i++) {
var result = results.get(i);
delete result.passcode;
}
}
} catch (e) {
throw new Error('caught error');
_server.throwApiException('Error in query handler.', ' Error in query handler.');
}
return results;
} else {
return _server.inner.query(bag, query, options);
}
}

queryHandler
results: [object ResultList]
org.mozilla.javascript.EvaluatorException: Constructor for "JavaException" not found. (Main#14)
at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:95)
at org.mozilla.javascript.Context.reportRuntimeError(Context.java:979)
at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1034)
at org.mozilla.javascript.Context.reportRuntimeError1(Context.java:997)
at org.mozilla.javascript.ScriptRuntime.getExistingCtor(ScriptRuntime.java:1119)
at org.mozilla.javascript.Context.newObject(Context.java:1459)
at org.mozilla.javascript.ScriptRuntime.newCatchScope(ScriptRuntime.java:2933)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3274)
at script.queryHandler(Main:14)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2248)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:158)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:337)
at dovetaildb.service.RhinoContextFactory.doTopCall(RhinoContextFactory.java:89)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2755)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:156)
at dovetaildb.service.ServiceJavascript.callJs(ServiceJavascript.java:235)
at dovetaildb.service.ServiceJavascript.query(ServiceJavascript.java:314)
at dovetaildb.service.ServiceSecurity.query(ServiceSecurity.java:180)
at dovetaildb.ApiService.query(ApiService.java:133)
at dovetaildb.servlet.ServerServlet.call(ServerServlet.java:265)
at dovetaildb.servlet.ServerServlet.handle(ServerServlet.java:150)
at dovetaildb.servlet.ServerServlet.doPost(ServerServlet.java:89)
at dovetaildb.servlet.ServerServlet.doGet(ServerServlet.java:201)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

psch...@gmail.com

unread,
Apr 16, 2009, 12:11:10 AM4/16/09
to dovetaildb-discuss
Thanks for the bug report! I've uploaded 0.3.8 which patches for this
issue - your function now works for me, provided I change ".size()" to
".length". See this thread for details:

http://groups.google.com/group/dovetaildb-discuss/browse_thread/thread/242c0dcfaeca287a/3663b39b6ac8d02f?hl=en#3663b39b6ac8d02f
Reply all
Reply to author
Forward
0 new messages