Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/SIL.Machine/Corpora/CorpusAlignmentException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ namespace SIL.Machine.Corpora
{
public class CorpusAlignmentException : Exception
{
public CorpusAlignmentException(string sourceRef, string targetRef)
public CorpusAlignmentException(string sourceRef, string targetRef, Exception innerException = null)
: base(
$"Invalid format in {sourceRef} and {targetRef}. Mismatched key formats \"{sourceRef}\" and \"{targetRef}\". There may be an extraneous tab, missing ref, or inconsistent use of user-defined refs."
$"Invalid format in {sourceRef} and {targetRef}. Mismatched key formats \"{sourceRef}\" and \"{targetRef}\". There may be an extraneous tab, missing ref, or inconsistent use of user-defined refs.",
innerException
) { }

public CorpusAlignmentException(string[] refs)
public CorpusAlignmentException(string[] refs, Exception innerException = null)
: base(
$"Invalid format in {string.Join(", ", refs)}. Mismatched key formats. There may be an extraneous tab, missing ref, or inconsistent use of user-defined refs."
$"Invalid format in {string.Join(", ", refs)}. Mismatched key formats. There may be an extraneous tab, missing ref, or inconsistent use of user-defined refs.",
innerException
) { }
}
}
11 changes: 7 additions & 4 deletions src/SIL.Machine/Corpora/NParallelTextCorpus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ private IEnumerable<NParallelTextRow> GetRows(IList<IEnumerator<TextRow>> enumer
)
.ToList();
}
catch (ArgumentException)
catch (ArgumentException e)
{
throw new CorpusAlignmentException(currentRows.Select(e => e.Ref.ToString()).ToArray());
throw new CorpusAlignmentException(
currentRows.Where(r => r != null).Select(r => r.Ref.ToString()).ToArray(),
e
);
}
List<int> nonMinRefIndexes = Enumerable.Range(0, N).Except(minRefIndexes).ToList();
if (minRefIndexes.Count < numberOfRemainingRows || minRefIndexes.Count(i => !completed[i]) == 1)
Expand Down Expand Up @@ -395,9 +398,9 @@ private bool CheckSameRefRows(IList<TextRow> sameRefRows, TextRow otherRow)
if (sameRefRows.Count > 0 && RowRefComparer.Compare(sameRefRows[0].Ref, otherRow.Ref) != 0)
sameRefRows.Clear();
}
catch (ArgumentException)
catch (ArgumentException e)
{
throw new CorpusAlignmentException(sameRefRows[0].Ref.ToString(), otherRow.Ref.ToString());
throw new CorpusAlignmentException(sameRefRows[0].Ref.ToString(), otherRow.Ref.ToString(), e);
}
return sameRefRows.Count > 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/SIL.Machine/Corpora/ParallelTextCorpus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public override IEnumerable<ParallelTextRow> GetRows(IEnumerable<string> textIds
? RowRefComparer.Compare(nRow.Ref, alignmentEnumerator.Current.Ref)
: 1;
}
catch (ArgumentException)
catch (ArgumentException e)
{
throw new CorpusAlignmentException(nRow.NRefs.Select(r => r.ToString()).ToArray());
throw new CorpusAlignmentException(nRow.NRefs.Select(r => r.ToString()).ToArray(), e);
}
} while (compareAlignmentCorpus < 0);
}
Expand Down
Loading