Skip to content

Commit

Permalink
Improve versification handling and stop crashing on Debug.Assert (#1397)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyonsil authored Dec 13, 2024
1 parent d795f89 commit 029c502
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion c-sharp/JsonUtils/VerseRefConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ JsonSerializerOptions options
bookName,
chapterNum.Value.ToString(),
verse ?? verseNum!.Value.ToString(),
new ScrVers(versification)
string.IsNullOrEmpty(versification) ? null : new ScrVers(versification)
);
}

Expand Down
14 changes: 7 additions & 7 deletions c-sharp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using Paranext.DataProvider.Checks;
using Paranext.DataProvider.NetworkObjects;
using Paranext.DataProvider.Projects;
Expand All @@ -16,13 +17,12 @@ public static async Task Main()
Console.WriteLine("Paranext data provider starting up");
Thread.CurrentThread.Name = "Main";

// Turn on additional logging to help diagnose failures on macOS
if (OperatingSystem.IsMacOS())
{
System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.ConsoleTraceListener());
System.Diagnostics.Trace.AutoFlush = true;
System.Diagnostics.Trace.WriteLine("Trace logging enabled");
}
var listener = new ConsoleTraceListener { TraceOutputOptions = TraceOptions.DateTime };
// Clear the default listeners to stop Debug.Assert from crashing the app
Trace.Listeners.Clear();
// Log all trace messages to the console
Trace.Listeners.Add(listener);
Trace.AutoFlush = true;

using PapiClient papi = new();
try
Expand Down
2 changes: 2 additions & 0 deletions c-sharp/Projects/ParatextProjectDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ Func<ScrText, VerseRef, string> getTextFromScrText
try
{
var scrText = LocalParatextProjects.GetParatextProject(ProjectDetails.Metadata.Id);
if (verseRef.Versification == null)
verseRef.Versification = scrText.Settings.Versification;
return getTextFromScrText(scrText, verseRef);
}
catch (Exception e) when (e is ArgumentException or ProjectNotFoundException)
Expand Down

0 comments on commit 029c502

Please sign in to comment.