import org.ibex.util.*;
import org.ibex.js.JS;
import org.ibex.js.JSScope;
+import org.ibex.js.JSExn;
public class JSElement extends JSScope implements XML.Element {
protected XML.Element wrapped;
declare(a.getKey(i));
put(a.getKey(i), eval(a.getVal(i)));
}
- } catch (Exception e) { throw new RuntimeException(e); }
+ } catch (JSExn e) { throw new Exn(e); }
}
private Object eval(String s) {
app instanceof String ||
app instanceof Number ||
app instanceof Boolean))
- throw new RuntimeException("javascripts within ${...} can only return " +
- "strings, numbers, and booleans; not a " +
- app.getClass().getName());
+ throw new Exn("javascripts within ${...} can only return " +
+ "strings, numbers, and booleans; not a " +
+ app.getClass().getName());
ret.append(app == null ? "null" : app.toString());
}
try {
return JS.eval(JS.cloneWithNewParentScope(
JS.fromReader("input", 0, new StringReader(s)), this));
- } catch (Exception e) {
+ } catch (IOException e) {
e.printStackTrace();
- throw new RuntimeException(e);
+ throw new Exn("impossible IOException, reading from StringReader");
+ } catch (JSExn e) {
+ throw new Exn(e);
}
}
return i >= a.attrSize() ? b.getUri(i-a.attrSize()) : a.getUri(i); }
public int attrSize() { return a.attrSize() + b.attrSize(); }
}
+
+ public static class Exn extends RuntimeException {
+ public Exn(String cause) { super(cause); }
+ public Exn(JSExn e) { super(e); }
+ public String toString() { return "JSElement.Exn: "+getMessage(); }
+ }
}