Skip to content

Commit

Permalink
Log full query in case RDF4J throws MalformedQueryException to help w…
Browse files Browse the repository at this point in the history
…ith diagnosing the problem.
  • Loading branch information
ledsoft committed May 23, 2023
1 parent 091feb1 commit 57c12eb
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -19,6 +19,7 @@
import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
import cz.cvut.kbss.ontodriver.rdf4j.connector.StatementExecutor;
import cz.cvut.kbss.ontodriver.rdf4j.exception.Rdf4jDriverException;
import org.eclipse.rdf4j.query.MalformedQueryException;
import org.eclipse.rdf4j.query.QueryEvaluationException;
import org.eclipse.rdf4j.query.QueryLanguage;
import org.eclipse.rdf4j.query.TupleQueryResult;
Expand Down Expand Up @@ -67,8 +68,12 @@ QuerySpecification querySpec(String sparql) {
return QuerySpecification.query(sparql).includeInference(!inferenceDisabled);
}

private static boolean isAskQuery(String query) {
return QueryParserUtil.parseOperation(QueryLanguage.SPARQL, query, null) instanceof ParsedBooleanQuery;
private static boolean isAskQuery(String query) throws Rdf4jDriverException {
try {
return QueryParserUtil.parseOperation(QueryLanguage.SPARQL, query, null) instanceof ParsedBooleanQuery;
} catch (MalformedQueryException e) {
throw new Rdf4jDriverException("Invalid query \"" + query + "\".", e);
}
}

@Override
Expand Down

0 comments on commit 57c12eb

Please sign in to comment.