Skip to content

Commit

Permalink
datafs: info: raise better FileNotFoundError (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Jul 27, 2023
1 parent 1483f63 commit 4617ead
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/dvc_data/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,16 @@ def ls(self, path, detail=True, **kwargs):

def info(self, path, **kwargs):
key = self._get_key(path)
info = self.index.info(key)

try:
info = self.index.info(key)
except KeyError as exc:
raise FileNotFoundError(
errno.ENOENT,
os.strerror(errno.ENOENT),
path,
) from exc

info["name"] = path
return info

Expand Down
2 changes: 0 additions & 2 deletions src/dvc_data/index/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,6 @@ def info(self, key: DataIndexKey):
entry = self[key]
except ShortKeyError:
entry = None
except KeyError as exc:
raise FileNotFoundError from exc

return self._info_from_entry(key, entry)

Expand Down

0 comments on commit 4617ead

Please sign in to comment.