Skip to content

Commit bae08d1

Browse files
seismanweiji14
andcommitted
Raise FileNotFoundError instead
Co-authored-by: Wei Ji <[email protected]>
1 parent 4d060f0 commit bae08d1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pygmt/accessors.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ def __init__(self, xarray_obj):
3232
try:
3333
self._source = self._obj.encoding["source"] # filepath to NetCDF source
3434
if not Path(self._source).exists():
35-
raise ValueError(f"Grid source file {self._source} doesn't exist.")
35+
raise FileNotFoundError(
36+
f"Grid source file {self._source} doesn't exist."
37+
)
3638
# Get grid registration and grid type from the last two columns of
3739
# the shortened summary information of `grdinfo`.
3840
self._registration, self._gtype = map(
3941
int, grdinfo(self._source, per_column="n").split()[-2:]
4042
)
41-
except (KeyError, ValueError):
43+
except (KeyError, ValueError, FileNotFoundError):
4244
self._registration = 0 # Default to Gridline registration
4345
self._gtype = 0 # Default to Cartesian grid type
4446

0 commit comments

Comments
 (0)