Skip to content

Conversation

@Enkidu93
Copy link
Collaborator

@Enkidu93 Enkidu93 commented Sep 25, 2025

Fixes sillsdev/serval#764 and fixes #332

  • Add custom exception
  • Add error handler
  • Fix mis-ported lines

As I began coding, I realized that the idea of 'error handler' wasn't concrete enough - there are a number of places and ways we could inject an error handler. We could also design this exception a couple different ways. This is all to say, please say 'That's not at all what I was thinking', @ddaspit, if that's the case 😆. I figured it was simpler just to put in the PR and discuss here.


This change is Reviewable

@Enkidu93 Enkidu93 requested a review from ddaspit September 25, 2025 17:53
@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.28%. Comparing base (13bf3d2) to head (532c321).

Files with missing lines Patch % Lines
src/SIL.Machine/Corpora/IUsfmUpdateBlockHandler.cs 0.00% 9 Missing ⚠️
...hine/Corpora/PlaceMarkersUsfmUpdateBlockHandler.cs 68.42% 5 Missing and 1 partial ⚠️
src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs 57.14% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #342      +/-   ##
==========================================
- Coverage   72.32%   72.28%   -0.04%     
==========================================
  Files         416      417       +1     
  Lines       35438    35467      +29     
  Branches     4897     4900       +3     
==========================================
+ Hits        25629    25638       +9     
- Misses       8711     8731      +20     
  Partials     1098     1098              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddaspit reviewed 2 of 3 files at r1.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion


src/SIL.Machine/Corpora/PlaceMarkersUsfmUpdateBlockHandler.cs line 42 at r1 (raw file):

        /// <param name="errorHandler">Error handler should return true if parsing should continue; error handler should return false if exception should be thrown. Default behavior is to rethrow. </param>
        /// </summary>
        public PlaceMarkersUsfmUpdateBlockHandler(Func<UsfmUpdateBlockHandlerException, bool> errorHandler = null)

It would be more generic if we pass in the error handler to the UpdateUsfmParserHandler class and wrapped the ProcessBlock call in a try/catch. What do you think?

Copy link
Collaborator Author

@Enkidu93 Enkidu93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @ddaspit)


src/SIL.Machine/Corpora/PlaceMarkersUsfmUpdateBlockHandler.cs line 42 at r1 (raw file):

Previously, ddaspit (Damien Daspit) wrote…

It would be more generic if we pass in the error handler to the UpdateUsfmParserHandler class and wrapped the ProcessBlock call in a try/catch. What do you think?

Yes, it would. That was the other option that was at the forefront of my mind.

The benefit of passing the error handler to the specific update block handlers is that it would allow more fine-grained control. For example, there may be situations in which, for a particular handler, we want the code to crash if a block cannot be processed (e.g., if we need that update to go through before being processed by a subsequent block or if it's integral to producing the USFM). If QuotationMarkDenormalizationFirstPass were implemented as a block handler instead, we might have that sort of issue.

Since this isn't something we need right now, I'll update the code to just pass it to the UpdateUsfmParserHandler. Need be, we could move it to the individual handlers or even just pass the handler instance into the error function to provide the caller more context.

@Enkidu93 Enkidu93 requested a review from ddaspit September 29, 2025 14:49
Copy link
Contributor

@ddaspit ddaspit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@ddaspit reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)

@Enkidu93 Enkidu93 merged commit 1bcb5fd into master Sep 29, 2025
4 checks passed
@Enkidu93 Enkidu93 deleted the update_block_error_handling branch September 29, 2025 18:08
Enkidu93 added a commit to sillsdev/machine.py that referenced this pull request Oct 2, 2025
Enkidu93 added a commit to sillsdev/machine.py that referenced this pull request Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot get pretranslated USFM for Isaiah 9 in DHH94 Custom UsfmUpdateBlock exception

4 participants