Skip to content

Commit

Permalink
[#231] Improve logging for query parse error in ApplyConstructModule
Browse files Browse the repository at this point in the history
  • Loading branch information
blcham committed Jul 5, 2024
1 parent 944f399 commit b516e7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.apache.jena.rdf.model.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.topbraid.spin.arq.ARQFactory;
import org.topbraid.spin.model.Construct;
import org.topbraid.spin.system.SPINModuleRegistry;
import org.topbraid.spin.vocabulary.SP;
Expand Down Expand Up @@ -134,7 +133,7 @@ public ExecutionContext executeSelf() {
if (parseText) {
query = QueryFactory.create(spinConstructRes.getProperty(SP.text).getLiteral().getString());
} else {
query = ARQFactory.get().createQuery(spinConstructRes);
query = QueryUtils.createQuery(spinConstructRes);
}

Model constructedModel = QueryUtils.execConstruct(query, extendedInferredModel, bindings);
Expand Down
10 changes: 10 additions & 0 deletions s-pipes-core/src/main/java/cz/cvut/spipes/util/QueryUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.apache.jena.sparql.mgt.Explain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.topbraid.spin.arq.ARQFactory;

import java.io.PrintWriter;
import java.io.StringWriter;
Expand Down Expand Up @@ -177,4 +178,13 @@ public static String getQueryComment(String query) {
return null;
}

public static Query createQuery(org.topbraid.spin.model.Query spinQuery) {
try {
return ARQFactory.get().createQuery(spinQuery);
} catch (QueryParseException e) {
String query = ARQFactory.get().createCommandString(spinQuery);
LOG.error("Parse error [1] occurred in query [2].\n[1] ERROR:\n{}\n[2] QUERY:\n{}", e.getMessage(), query);
throw e;
}
}
}

0 comments on commit b516e7a

Please sign in to comment.