Skip to content

Commit

Permalink
ENH: Log more information when NRRD reading fails (#7700)
Browse files Browse the repository at this point in the history
When some required fields in the NRRD file were missing, the user just got a generic error message.
This commit logs detailed information about why Teem library could not load the NRRD file.

see https://discourse.slicer.org/t/slicer-rejects-modified-header/35549
  • Loading branch information
lassoan committed Apr 18, 2024
1 parent 98e542e commit 230acbd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Libs/vtkTeem/vtkTeemNRRDReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ int vtkTeemNRRDReader::CanReadFile(const char* filename)
if (nrrdLoad(nrrdTemp, filename, nio) != 0)
{
supported = false;
// We have already checked the magic, so the file should be readable.
// If it is not readable then it is an error, which we should report
// to make troubleshooting easier.
char* err = biffGetDone(NRRD);
if (err)
{
vtkErrorMacro("CanReadFile failed: " << err);
free(err);
}
}
if (nrrdTypeBlock == nrrdTemp->type)
{
Expand Down

0 comments on commit 230acbd

Please sign in to comment.