Catch all exceptions in Xml.read().
Nicer error messages.
This commit is contained in:
parent
5c0ec5544a
commit
3c561e4003
1 changed files with 6 additions and 6 deletions
|
@ -60,13 +60,13 @@ public class DomExtension extends Extension {
|
||||||
}
|
}
|
||||||
public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
|
public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
|
||||||
if ( arguments==null || arguments.length != 2 )
|
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;
|
INode node = null;
|
||||||
try {
|
try {
|
||||||
node = ((ESNode)arguments[0]).getNode();
|
node = ((ESNode)arguments[0]).getNode();
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
// we definitly need a node
|
// 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 {
|
try {
|
||||||
File tmpFile = new File(arguments[1].toString()+".tmp."+XmlWriter.generateID());
|
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 {
|
public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
|
||||||
if ( arguments==null || arguments.length==0 )
|
if ( arguments==null || arguments.length==0 )
|
||||||
throw new EcmaScriptException("not enough arguments");
|
throw new EcmaScriptException("Not enough arguments in Xml.writeToString()");
|
||||||
INode node = null;
|
INode node = null;
|
||||||
try {
|
try {
|
||||||
node = ((ESNode)arguments[0]).getNode();
|
node = ((ESNode)arguments[0]).getNode();
|
||||||
|
@ -126,7 +126,7 @@ public class DomExtension extends Extension {
|
||||||
}
|
}
|
||||||
public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
|
public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
|
||||||
if ( arguments==null || arguments.length==0 )
|
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;
|
INode node = null;
|
||||||
try {
|
try {
|
||||||
node = ((ESNode)arguments[1]).getNode();
|
node = ((ESNode)arguments[1]).getNode();
|
||||||
|
@ -143,8 +143,8 @@ public class DomExtension extends Extension {
|
||||||
result = reader.read (new File(arguments[0].toString()),node);
|
result = reader.read (new File(arguments[0].toString()),node);
|
||||||
return this.evaluator.reval.getNodeWrapper (result);
|
return this.evaluator.reval.getNodeWrapper (result);
|
||||||
} catch ( NoClassDefFoundError e ) {
|
} catch ( NoClassDefFoundError e ) {
|
||||||
throw new EcmaScriptException ("Can't load dom-capable xml parser.");
|
throw new EcmaScriptException ("Can't load XML parser:"+e);
|
||||||
} catch ( RuntimeException f ) {
|
} catch ( Exception f ) {
|
||||||
throw new EcmaScriptException (f.toString());
|
throw new EcmaScriptException (f.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue