use of org.apache.jena.shared.JenaException in project jena by apache.
the class ParserARQ method perform.
// All throwable handling.
private static void perform(Query query, String string, Action action) {
Reader in = new StringReader(string);
ARQParser parser = new ARQParser(in);
try {
query.setStrict(true);
parser.setQuery(query);
action.exec(parser);
} catch (org.apache.jena.sparql.lang.arq.ParseException ex) {
throw new QueryParseException(ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginColumn);
} catch (org.apache.jena.sparql.lang.arq.TokenMgrError tErr) {
// Last valid token : not the same as token error message - but this should not happen
int col = parser.token.endColumn;
int line = parser.token.endLine;
throw new QueryParseException(tErr.getMessage(), line, col);
} catch (QueryException ex) {
throw ex;
} catch (JenaException ex) {
throw new QueryException(ex.getMessage(), ex);
} catch (Error err) {
// The token stream can throw errors.
throw new QueryParseException(err.getMessage(), err, -1, -1);
} catch (Throwable th) {
Log.warn(ParserSPARQL11.class, "Unexpected throwable: ", th);
throw new QueryException(th.getMessage(), th);
}
}
use of org.apache.jena.shared.JenaException in project jena by apache.
the class TestReifier method getGraph.
@Override
public Graph getGraph() {
try {
Constructor<?> cons = getConstructor(graphClass, new Class[] {});
if (cons != null)
return (Graph) cons.newInstance();
Constructor<?> cons2 = getConstructor(graphClass, new Class[] { this.getClass() });
if (cons2 != null)
return (Graph) cons2.newInstance(this);
throw new JenaException("no suitable graph constructor found for " + graphClass);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new JenaException(e);
}
}
use of org.apache.jena.shared.JenaException in project jena by apache.
the class DatasetGraphAccessorHTTP method target.
protected final String target(Node name) {
if (!name.isURI())
throw new JenaException("Not a URI: " + name);
String guri = name.getURI();
// Encode
guri = IRILib.encodeUriComponent(guri);
return remote + "?" + HttpNames.paramGraph + "=" + guri;
}
use of org.apache.jena.shared.JenaException in project jena by apache.
the class TransactionHandlerContractTest method testExecuteInTransactionCatchesThrowable.
@SuppressWarnings("deprecation")
@ContractTest
public void testExecuteInTransactionCatchesThrowable() {
TransactionHandler th = getTransactionHandlerProducer().newInstance();
if (th.transactionsSupported()) {
Command cmd = new Command() {
@Override
public Object execute() throws Error {
throw new Error();
}
};
try {
th.executeInTransaction(cmd);
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
try {
th.execute(() -> {
throw new Error();
});
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
try {
th.calculate(() -> {
throw new Error();
});
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
}
}
use of org.apache.jena.shared.JenaException in project jena by apache.
the class GraphHelper method getGraph.
/**
* Answer an instance of <code>graphClass</code>. If <code>graphClass</code>
* has a constructor that takes a <code>ReificationStyle</code> argument,
* then that constructor is run on <code>style</code> to get the instance.
* Otherwise, if it has a # constructor that takes an argument of
* <code>wrap</code>'s class before the <code>ReificationStyle</code>, that
* constructor is used; this allows non-static inner classes to be used for
* <code>graphClass</code>, with <code>wrap</code> being the outer class
* instance. If no suitable constructor exists, a JenaException is thrown.
*
* @param wrap
* the outer class instance if graphClass is an inner class
* @param graphClass
* a class implementing Graph
* @return an instance of graphClass with the given style
* @throws RuntimeException
* or JenaException if construction fails
*/
public static Graph getGraph(Object wrap, Class<? extends Graph> graphClass) {
try {
Constructor<?> cons = getConstructor(graphClass, new Class[] {});
if (cons != null)
return (Graph) cons.newInstance(new Object[] {});
Constructor<?> cons2 = getConstructor(graphClass, new Class[] { wrap.getClass() });
if (cons2 != null)
return (Graph) cons2.newInstance(new Object[] { wrap });
throw new JenaException("no suitable graph constructor found for " + graphClass);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new JenaException(e);
}
}
Aggregations