Ejemplo n.º 1
0
  @Override
  public Expr inline(final QueryContext qc, final VarScope scp, final Var var, final Expr ex)
      throws QueryException {

    boolean change = false;
    try {
      final Expr sub = expr.inline(qc, scp, var, ex);
      if (sub != null) {
        if (sub.isValue()) return optPre(sub, qc);
        expr = sub;
        change = true;
      }
    } catch (final QueryException qe) {
      if (!qe.isCatchable()) throw qe;
      for (final Catch c : catches) {
        if (c.matches(qe)) {
          // found a matching clause, inline variable and error message
          final Catch nw = c.inline(qc, scp, var, ex);
          return optPre((nw == null ? c : nw).asExpr(qe, qc, scp), qc);
        }
      }
      throw qe;
    }

    for (final Catch c : catches) change |= c.inline(qc, scp, var, ex) != null;
    return change ? this : null;
  }
Ejemplo n.º 2
0
 /**
  * Processes the HTTP request. Parses new modules and discards obsolete ones.
  *
  * @param http HTTP context
  * @throws Exception exception
  */
 void process(final HTTPContext http) throws Exception {
   try {
     module.process(http, this);
   } catch (final QueryException ex) {
     if (ex.file() == null) ex.info(function.info);
     throw ex;
   }
 }
Ejemplo n.º 3
0
 @Override
 public Value value(final QueryContext qc) throws QueryException {
   // don't catch errors from error handlers
   try {
     return qc.value(expr);
   } catch (final QueryException ex) {
     if (!ex.isCatchable()) throw ex;
     for (final Catch c : catches) if (c.matches(ex)) return c.value(qc, ex);
     throw ex;
   }
 }
Ejemplo n.º 4
0
 /** Test query. Detects malformed namespace hierarchy. */
 @Test
 @Ignore
 public void xuty0004() {
   final String query =
       "declare variable $input-context external;"
           + "let $source as node()* := ("
           + "    <status>on leave</status>,"
           + "    <!-- for 6 months -->"
           + "  ),"
           + "  $target := $input-context/works[1]/employee[1]"
           + "return insert nodes $source into $target";
   try (final QueryProcessor qp = new QueryProcessor(query, context)) {
     qp.value();
   } catch (final QueryException ex) {
     assertEquals("XUTY0004", ex.error().code);
   }
   fail("should throw XUTY0004");
 }
Ejemplo n.º 5
0
  @Override
  public Expr compile(final QueryContext qc, final VarScope scp) throws QueryException {
    try {
      super.compile(qc, scp);
      if (expr.isValue()) return optPre(expr, qc);
    } catch (final QueryException ex) {
      if (!ex.isCatchable()) throw ex;
      for (final Catch c : catches) {
        if (c.matches(ex)) {
          // found a matching clause, compile and inline error message
          return optPre(c.compile(qc, scp).asExpr(ex, qc, scp), qc);
        }
      }
      throw ex;
    }

    for (final Catch c : catches) c.compile(qc, scp);
    return optimize(qc, scp);
  }