Skip to content

TdmsFile raises misleading FileExistsError when TDMS file path does not exist #16

Description

@HasbunWoodEngineering

When opening a TDMS file with TdmsFile, nitdms raises FileExistsError if the provided path does not exist. This is misleading, because the actual problem is that the file is missing or the relative path resolves incorrectly.

Example:

from nitdms import TdmsFile

tf = TdmsFile("missing_file.tdms")

Expected

FileNotFoundError

Actual

FileExistsError

The issue appears to come from this line:
https://github.com/l-johnston/nitdms/blob/master/nitdms/tdsapi.py#L702

Suggested Fix

if not self._file.exists():
    raise FileNotFoundError(self._file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions