Skip to content

Split error formatting (tags to text) from error reporting (logging, html, etc.) - #292

Merged
mrbean-bremen merged 12 commits into
pydicom:mainfrom
p-j-smith:paul/291-base-error-message
Sep 8, 2026
Merged

mrbean-bremen merged 12 commits into
pydicom:mainfrom
p-j-smith:paul/291-base-error-message

Conversation

@p-j-smith

@p-j-smith p-j-smith commented Sep 3, 2026 •

Copy link
Copy Markdown

Describe the changes

Closes #291

  • added a new ValidationResultFormatter class that is responsible for converting tag errors into a human-readable format. It has error_message and failed_validation_message methods.
  • LoggingResultHandler.error_message, LoggingResultHandler.failed_validation_message, and HtmlResultHandler.error_message are now thin wrappers around the corresponding new methods. I've kept these method only to avoid introducing breaking changes.
  • added a HtmlResultHandler.handle_failed_validation_start function to report that validation could not be performed
  • added a NullValidationResultHandler class (same as is currently in the docs) just for convenience for users
  • added usage docs for the new formatter class and how to use this with the null handler
  • added tests for the new classes and methods

Note, this does change the output of the HtmlValidationResultHandler (it's more verbose, e.g. EnumValueNotAllowed now lists the allowed values, same as the LoggingValidationResultHandler does.). I assumed these could be treated as fixes or improvements rather than breaking changes?

Happy to break this PR up if there are too many changes here

Tasks

  • Unit tests added that reproduce the issue or prove feature is working
  • Fix or feature added
  • Entry to release notes added
  • Pre-commit CI shows no errors
  • For documentation changes: docs build succeeded and documentation looks as expected
  • Unit tests passing

@p-j-smith p-j-smith changed the title Paul/291 base error message Split error formatting (tags to text) from error reporting (logging, html, etc.) Sep 3, 2026
@codecov-commenter

codecov-commenter commented Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.96970% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.37%. Comparing base (e8644e2) to head (6724e9d).
⚠️ Report is 216 commits behind head on main.

Files with missing lines Patch % Lines
dicom_validator/validator/error_handler.py 96.36% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #292      +/-   ##
==========================================
+ Coverage   89.82%   90.37%   +0.54%     
==========================================
  Files          15       21       +6     
  Lines        1632     2120     +488     
==========================================
+ Hits         1466     1916     +450     
- Misses        166      204      +38     

☔ View full report in Codecov by Harness.
📢 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.

Paul Smith added 2 commits September 7, 2026 09:09
Also remove LoggingResultHandler.error_message and HtmlErrorHandler.error_message/tag_name

@mrbean-bremen mrbean-bremen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very nice, thanks a lot! Only a couple of minor suggestions.

"""Renders `TagError` and `ValidationResult` objects as human-readable text."""

def __init__(self, dictionary: dict | None = None) -> None:
"""Initialise the formatter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please use American English for consistence (yeah, I know...)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've begrudgingly changed it 🙂

Comment thread doc/source/api_usage.rst Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably not worth to duplicate the implementation here - you may just reference the new null handler.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

good point, I've removed it now

@mrbean-bremen
mrbean-bremen merged commit e911409 into pydicom:main Sep 8, 2026
18 checks passed
@mrbean-bremen

Copy link
Copy Markdown
Member

Thanks!

@mrbean-bremen

Copy link
Copy Markdown
Member

Note that I just made a new release.

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.

Suggestion to move LoggingResultHandler.error_message to ValidationResultHandlerBase.error_message

3 participants