Skip to content

improve error messages: distinguish permission from file-not-found #1506

@rmsppu

Description

@rmsppu

Describe the bug
When an unreadable input file is specified, the error message returned could be more helpful. The error message is that that the file wasn't found, which is true in the sense that the contents of the parent directory are unreadable, but "file not found" can be distinguished from "some component in the path has permissions that prevents reading the file (if it even exists)".

To Reproduce

  1. Confirm that a valid DICOM exists but is unreadable due to permissions:
/path/to/an/unreadable/file/DET0001_03.dcm: DICOM medical imaging data
$ ls -l /path/to/an/unreadable/file/DET0001_03.dcm
ls: cannot access /path/to/an/unreadable/file/DET0001_03.dcm: Permission denied
  1. Run CaPTk, specifying the unreadable file as input:
    BreastTexturePipeline -i /path/to/an/unreadable/file/DET0001_03.dcm -o unc_test/ -d 1
    Starting pre-processing.
    [getFilenameExtension()] Supplied file name '/path/to/an/unreadable/file/DET0001_03.dcm' wasn't found.


**Preferred behavior**
The error message should distinguish various cases, such as:

- File not found (ie., the directory path was valid and readable, but the specified file doesn't exist).
- File not found due to directory permissions (ie., permissions on a directory component prohibit checking if the file exists or not)
- File not readable due to permissions (ie., the permissions on the directory path allow stat(filename), but the content is unreadable due to permissions)

**CaPTk Version**
Linux, 1.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions