Skip to content

Commit

Permalink
GH-4867 change from Exception to Throwable so that we can also log St…
Browse files Browse the repository at this point in the history
…ackOverflowError and which shape caused it (#4909)
  • Loading branch information
hmottestad authored Feb 19, 2024
2 parents 2306c8b + a328662 commit 8ffccdf
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static ValidationReport validate(Sail dataRepo, Sail shapesRepo) {

}
shapesConnection.commit();
} catch (Exception e) {
} catch (Throwable e) {
logger.warn("Failed to read shapes", e);
throw e;
}
Expand All @@ -98,7 +98,7 @@ public static ValidationReport validate(Sail dataRepo, Sail shapesRepo) {
return performValidation(shapes, new ConnectionsGroup(verySimpleRdfsBackwardsChainingConnection, null,
null, null, new Stats(), () -> reasoner,
new ShaclSailConnection.Settings(true, true, true, IsolationLevels.NONE), true));
} catch (Exception e) {
} catch (Throwable e) {
logger.warn("Failed to validate shapes", e);
throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ public ShapeValidationContainer(Shape shape, Supplier<PlanNode> planNodeSupplier
} else {
this.planNode = planNode;
}
} catch (Exception e) {
} catch (Throwable e) {
logger.warn("Error processing SHACL Shape {}", shape.getId(), e);
logger.warn("Error processing SHACL Shape\n{}", shape, e);
if (e instanceof Error) {
throw e;
}
throw new SailException("Error processing SHACL Shape " + shape.getId() + "\n" + shape, e);
}

Expand All @@ -76,8 +81,12 @@ public ValidationResultIterator performValidation() {
try (CloseableIteration<? extends ValidationTuple, SailException> iterator = planNode.iterator()) {
validationResults = new ValidationResultIterator(iterator, effectiveValidationResultsLimitPerConstraint);
return validationResults;
} catch (Exception e) {
} catch (Throwable e) {
logger.warn("Error validating SHACL Shape {}", shape.getId(), e);
logger.warn("Error validating SHACL Shape\n{}", shape, e);
if (e instanceof Error) {
throw e;
}
throw new SailException("Error validating SHACL Shape " + shape.getId() + "\n" + shape, e);
} finally {
handlePostLogging(before, validationResults);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,9 @@ public PlanNode generatePlans(ConnectionsGroup connectionsGroup, ValidationSetti
} else {
throw new ShaclUnsupportedException("Unknown validation approach: " + validationApproach);
}
} catch (RuntimeException e) {
} catch (Throwable e) {
logger.warn("Error processing SHACL Shape {}", id, e);
logger.warn("Error processing SHACL Shape\n{}", this, e);
throw new SailException("Error processing SHACL Shape " + id + "\n" + this, e);
}

Expand Down Expand Up @@ -707,7 +708,7 @@ public static List<ContextWithShape> getShapesInContext(ShapeSource shapeSource,
.map(r -> {
try {
return new ShaclProperties(r, shapeSourceWithContext);
} catch (Exception e) {
} catch (Throwable e) {
logger.warn("Error parsing shape {}", r, e);
throw new ShaclShapeParsingException(e, r);
}
Expand All @@ -720,7 +721,7 @@ public static List<ContextWithShape> getShapesInContext(ShapeSource shapeSource,
return PropertyShape.getInstance(p, shapeSourceWithContext, parseSettings, cache);
}
throw new ShaclShapeParsingException("Unknown shape type", p.getId());
} catch (Exception e) {
} catch (Throwable e) {
logger.warn("Error parsing shape {}", p.getId(), e);
if (e instanceof ShaclShapeParsingException) {
throw e;
Expand All @@ -746,6 +747,7 @@ public String toString() {
statements.setNamespace(RSX.NS);
statements.setNamespace(RDFS.NS);
statements.setNamespace(RDF.NS);
statements.setNamespace(DASH.NS);
WriterConfig writerConfig = new WriterConfig()
.set(BasicWriterSettings.PRETTY_PRINT, true)
.set(BasicWriterSettings.INLINE_BLANK_NODES, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private void evaluateLazyAspect() {
validationResultIterators = null;

}
} catch (Exception e) {
} catch (Throwable e) {
logger.warn("Error evaluating lazy validation report", e);
throw e;
}
Expand All @@ -104,7 +104,7 @@ public Model asModel(Model model) {
}

return model;
} catch (Exception e) {
} catch (Throwable e) {
logger.warn("Error converting validation report to model", e);
throw e;
}
Expand Down

0 comments on commit 8ffccdf

Please sign in to comment.