From b422f4d663d59b674c8d30584060e2d598827bde Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Wed, 9 Jan 2002 23:45:27 +0000 Subject: [PATCH] fixed bugs in the Find script and also rigged ScriptManager to better handle the JavaScript native errors that crop up occasionally --- scripts/conf/find.js | 12 ++++++------ .../venice/ui/script/ScriptManager.java | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/scripts/conf/find.js b/scripts/conf/find.js index 2a63e3f..fd397ce 100644 --- a/scripts/conf/find.js +++ b/scripts/conf/find.js @@ -80,23 +80,23 @@ try { // do the search if (topic!=null) { // search the topic - view.results = topic.searchPosts(term,offset,view.maxResults); + view.results = topic.searchPosts(view.term,view.offset,view.maxResults); if (view.findCount<0) - view.findCount = topic.getSearchPostCount(term); + view.findCount = topic.getSearchPostCount(view.term); } // end if else if (conf!=null) { // search the conference - view.results = conf.searchPosts(term,offset,view.maxResults); + view.results = conf.searchPosts(view.term,view.offset,view.maxResults); if (view.findCount<0) - view.findCount = conf.getSearchPostCount(term); + view.findCount = conf.getSearchPostCount(view.term); } // end else if else { // search the community - view.results = comm.searchPosts(term,offset,view.maxResults); + view.results = comm.searchPosts(view.term,view.offset,view.maxResults); if (view.findCount<0) - view.findCount = comm.getSearchPostCount(term); + view.findCount = comm.getSearchPostCount(view.term); } // end else diff --git a/src/com/silverwrist/venice/ui/script/ScriptManager.java b/src/com/silverwrist/venice/ui/script/ScriptManager.java index d03fde7..3c7fb3b 100644 --- a/src/com/silverwrist/venice/ui/script/ScriptManager.java +++ b/src/com/silverwrist/venice/ui/script/ScriptManager.java @@ -222,6 +222,21 @@ public class ScriptManager } // end fixupRhino + private static void translateReturnedObject(ScriptReturn sro) throws ScriptingException + { + Object obj = sro.get(); + if (obj==null) + return; // nothing to do + + Class klass = obj.getClass(); + final String klassname = klass.getName(); + + // Special processing for JavaScript NativeError objects + if (klassname.equals("org.mozilla.javascript.NativeError")) + throw new ScriptingException("JavaScript runtime error: " + obj.toString()); + + } // end translateReturnedObject + private void translateScriptException(String source, String lang, BSFException e) throws ScriptingException, ThrowableContent { @@ -338,6 +353,10 @@ public class ScriptManager } // end finally + // if we've gotten this far, see if the returned object is actually an error that needs + // translation before it can be presented to the world + translateReturnedObject(sro); + } // end exec public void register(String name, Object obj)