r9732 - helma-ng/trunk/src/org/helma/tools
[email protected] Tue, 12 May 2009 16:14:41 +0200 (CEST)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20090512141441.08D573D0D6@mia> |
Author: hannes
Date: 2009-05-12 16:14:40 +0200 (Tue, 12 May 2009)
New Revision: 9732
Modified:
helma-ng/trunk/src/org/helma/tools/HelmaRunner.java
helma-ng/trunk/src/org/helma/tools/HelmaShell.java
Log:
Catch exceptions in HelmaRunner.main() and generate better error messages.
Details at http://dev.helma.org/trac/helma/changeset/9732
Modified: helma-ng/trunk/src/org/helma/tools/HelmaRunner.java
===================================================================
--- helma-ng/trunk/src/org/helma/tools/HelmaRunner.java 2009-05-12 14:14:34 UTC (rev 9731)
+++ helma-ng/trunk/src/org/helma/tools/HelmaRunner.java 2009-05-12 14:14:40 UTC (rev 9732)
@@ -21,7 +21,7 @@
public class HelmaRunner {
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) {
String scriptName = null;
String[] scriptArgs = new String[0];
boolean interactive = false;
@@ -73,18 +73,29 @@
if (modulePath == null) {
modulePath = System.getenv("HELMA_MODULE_PATH");
}
- HelmaConfiguration config = new HelmaConfiguration(home, modulePath, "modules");
- config.addScriptRepository(scriptName);
- if (optlevel >= -1) {
- config.setOptLevel(optlevel);
+
+ try {
+ HelmaConfiguration config = new HelmaConfiguration(home, modulePath, "modules");
+ config.addScriptRepository(scriptName);
+ if (optlevel >= -1) {
+ config.setOptLevel(optlevel);
+ }
+ RhinoEngine engine = new RhinoEngine(config, null);
+ if (scriptName != null) {
+ engine.runScript(scriptName, scriptArgs);
+ }
+ if (scriptName == null || interactive) {
+ new HelmaShell(config, engine, debug).run();
+ }
+ } catch (Exception x) {
+ if (debug) {
+ x.printStackTrace();
+ } else {
+ System.err.println(x);
+ }
+ System.exit(-1);
}
- RhinoEngine engine = new RhinoEngine(config, null);
- if (scriptName != null) {
- engine.runScript(scriptName, scriptArgs);
- }
- if (scriptName == null || interactive) {
- new HelmaShell(config, engine, debug).run();
- }
+
}
public static void printUsage() {
Modified: helma-ng/trunk/src/org/helma/tools/HelmaShell.java
===================================================================
--- helma-ng/trunk/src/org/helma/tools/HelmaShell.java 2009-05-12 14:14:34 UTC (rev 9731)
+++ helma-ng/trunk/src/org/helma/tools/HelmaShell.java 2009-05-12 14:14:40 UTC (rev 9732)
@@ -44,7 +44,7 @@
boolean debug;
public HelmaShell(HelmaConfiguration config, RhinoEngine engine, boolean debug)
- throws Exception {
+ throws IOException {
this.config = config;
this.engine = engine;
this.scope = engine.getShellScope();