Skip to content

Commit fd73462

Browse files
committed
Append filename to h5py-raised OSErrors
The filename isn't always present in the exception, this appends it to the exception argument for convenience.
1 parent 9e51a11 commit fd73462

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

stagpy/stagyyparsers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,13 @@ def _read_group_h5(filename, groupname):
513513
Returns:
514514
:class:`numpy.array`: content of group.
515515
"""
516-
with h5py.File(filename, 'r') as h5f:
517-
data = h5f[groupname][()]
516+
try:
517+
with h5py.File(filename, 'r') as h5f:
518+
data = h5f[groupname][()]
519+
except OSError as err:
520+
# h5py doesn't always include the filename in its error messages
521+
err.args += (filename,)
522+
raise
518523
return data # need to be reshaped
519524

520525

0 commit comments

Comments
 (0)