Skip to content

BUG: Set error messages in H5OIMReader and H5EspritReader - #70

Closed
imikejackson wants to merge 1 commit into
BlueQuartzSoftware:developfrom
imikejackson:issue69-reader-error-messages
Closed

imikejackson wants to merge 1 commit into
BlueQuartzSoftware:developfrom
imikejackson:issue69-reader-error-messages

Conversation

@imikejackson

Copy link
Copy Markdown
Collaborator

Closes #69.

Problem

H5OIMReader and H5EspritReader set an error code but leave the error message empty. In each of 23 error branches, the code writes the message into a std::stringstream built from an empty std::string, then passes that empty string to setErrorMessage(). Programs that show the reader's message, such as the simplnx Read EDAX OIMAnalysis Data (.h5) and Read Bruker Nano Esprit Data (.h5) filters, show nothing.

There is a second defect in the same functions. When H5EspritReader::readHeaderOnly() or readFile() cannot open the HDF5 file, they return 0 (success), because they return err from sanityCheckForOpening(). getErrorCode() is -2. The issue notes this defect, and a new unit test confirms it. It is fixed in this PR.

Changes

  • All 23 branches call setErrorMessage(ss.str()) and no longer create the unused std::string.
  • The "could not read header" and "could not read data" branches now put the detailed message from readHeader()/readData() after their own message, so that detail is kept. Before, H5EspritReader did not set a message in these branches, and H5OIMReader replaced the detail with an empty message.
  • H5EspritReader::readFile() and readHeaderOnly() return getErrorCode() (-2) when the file cannot be opened.
  • No error codes changed.

Tests

  • EdaxOIMReaderTest::HeaderErrorHasMessage: a missing file. readHeaderOnly() and readFile() return a value below 0, and the message contains the file path.
  • H5EspritReaderTest::MissingFileHasError: a missing file. Both functions return a value below 0, the error code is -2, and the message contains the file path.
  • H5EspritReaderTest::MissingScanHasMessage: a valid file with a scan path that does not exist. The error code is -90020, and the message contains the scan path.

All three tests fail before the fix: Esprit readHeaderOnly() and readFile() return 0, and the messages are empty. All 431 tests pass after the fix (macOS arm64, Release).

🤖 Generated with Claude Code

…Software#69)

Each error branch wrote its message into a std::stringstream built from an
empty std::string and then passed that empty string to setErrorMessage(),
so the reader's error message was always empty. Use ss.str() instead.

The "could not read header" and "could not read data" branches now put the
detailed message from readHeader()/readData() after their own message, so
that detail is kept. Before, H5EspritReader did not set a message there,
and H5OIMReader replaced the detail with an empty message.

H5EspritReader::readFile() and readHeaderOnly() returned 0 (success) when
the HDF5 file could not be opened. They now return the error code (-2).

Adds regression tests for a missing file (both readers) and for a missing
scan path (H5EspritReader).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@imikejackson

Copy link
Copy Markdown
Collaborator Author

Closed in favor of #86, which merges this branch (with its history) together with the other open EbsdLib fixes for the next release, so simplnx can build against one EbsdLib branch. The branch is kept.

🤖 Generated with Claude Code

@imikejackson
imikejackson deleted the issue69-reader-error-messages branch November 13, 2026 16:28
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.

BUG: H5OIMReader and H5EspritReader set empty error messages

1 participant