From 3c561e40037f2affb650c1560bbb3d64b36316fb Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 11 Sep 2002 15:59:37 +0000 Subject: [PATCH] Catch all exceptions in Xml.read(). Nicer error messages. --- .../scripting/fesi/extensions/DomExtension.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/helma/scripting/fesi/extensions/DomExtension.java b/src/helma/scripting/fesi/extensions/DomExtension.java index 1fec487e..db224bce 100644 --- a/src/helma/scripting/fesi/extensions/DomExtension.java +++ b/src/helma/scripting/fesi/extensions/DomExtension.java @@ -60,13 +60,13 @@ public class DomExtension extends Extension { } public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException { if ( arguments==null || arguments.length != 2 ) - throw new EcmaScriptException("wrong number of arguments"); + throw new EcmaScriptException("Wrong number of arguments in Xml.write()"); INode node = null; try { node = ((ESNode)arguments[0]).getNode(); } catch ( Exception e ) { // we definitly need a node - throw new EcmaScriptException("first argument is not an hopobject"); + throw new EcmaScriptException("First argument in Xml.write() is not an hopobject"); } try { File tmpFile = new File(arguments[1].toString()+".tmp."+XmlWriter.generateID()); @@ -94,7 +94,7 @@ public class DomExtension extends Extension { } public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException { if ( arguments==null || arguments.length==0 ) - throw new EcmaScriptException("not enough arguments"); + throw new EcmaScriptException("Not enough arguments in Xml.writeToString()"); INode node = null; try { node = ((ESNode)arguments[0]).getNode(); @@ -126,7 +126,7 @@ public class DomExtension extends Extension { } public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException { if ( arguments==null || arguments.length==0 ) - throw new EcmaScriptException("no arguments for Xml.load()"); + throw new EcmaScriptException("Missing arguments in Xml.read()"); INode node = null; try { node = ((ESNode)arguments[1]).getNode(); @@ -143,8 +143,8 @@ public class DomExtension extends Extension { result = reader.read (new File(arguments[0].toString()),node); return this.evaluator.reval.getNodeWrapper (result); } catch ( NoClassDefFoundError e ) { - throw new EcmaScriptException ("Can't load dom-capable xml parser."); - } catch ( RuntimeException f ) { + throw new EcmaScriptException ("Can't load XML parser:"+e); + } catch ( Exception f ) { throw new EcmaScriptException (f.toString()); } }