Skip to content

Commit 8d8b14b

Browse files
committed
JGitDiff better error message
1 parent ae15dab commit 8d8b14b

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/main/java/org/variantsync/diffdetective/variation/diff/construction/JGitDiff.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.variantsync.diffdetective.variation.diff.construction;
22

33
import org.eclipse.jgit.diff.*;
4+
import org.tinylog.Logger;
45
import org.variantsync.diffdetective.diff.git.GitDiffer;
56
import org.variantsync.diffdetective.diff.result.DiffParseException;
67
import org.variantsync.diffdetective.variation.DiffLinesLabel;
@@ -92,7 +93,18 @@ Using our own formatter without diff headers (paired with a maximum context (?))
9293
//textDiff = textDiff.replace("\\ No newline at end of file\n", "");
9394
//textDiff = HUNK_HEADER_REGEX.matcher(textDiff).replaceAll("");
9495

95-
final VariationDiff<DiffLinesLabel> d = VariationDiffParser.createVariationDiff(textDiff, options);
96+
final VariationDiff<DiffLinesLabel> d;
97+
try {
98+
d = VariationDiffParser.createVariationDiff(textDiff, options);
99+
} catch (DiffParseException e) {
100+
Logger.error("""
101+
Could not parse diff:
102+
103+
{}
104+
""",
105+
textDiff);
106+
throw e;
107+
}
96108
d.setSource(new PatchString(textDiff));
97109
return d;
98110
}

src/main/java/org/variantsync/diffdetective/variation/diff/view/DiffView.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ private static <L extends Label> VariationDiff<DiffLinesLabel> naive(final Varia
7474
try {
7575
view = JGitDiff.diff(projectionViewText[0], projectionViewText[1], DiffAlgorithm.SupportedAlgorithm.MYERS, Main.VARIATION_DIFF_PARSE_OPTIONS);
7676
} catch (DiffParseException e) {
77-
Logger.error("""
78-
Could not parse diff obtained with query {} at {}:
79-
Diff:
80-
""",
81-
d.getSource(), rho);
77+
Logger.error("Could not parse diff obtained with query {} at {}", d.getSource(), rho);
8278
throw e;
8379
}
8480
view.setSource(new ViewSource<>(d, rho));

0 commit comments

Comments
 (0)