Skip to content

Commit 851d85b

Browse files
authored
Protect against an exception raised by python-eccodes (#5139)
Related to #5138
1 parent 186c2ff commit 851d85b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

xarray/backends/cfgrib_.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
except ModuleNotFoundError:
2323
has_cfgrib = False
2424
# cfgrib throws a RuntimeError if eccodes is not installed
25-
except RuntimeError:
25+
except (ImportError, RuntimeError):
2626
warnings.warn(
27-
"Failed to load cfgrib - most likely eccodes is missing. Try `import cfgrib` to get the error message"
27+
"Failed to load cfgrib - most likely there is a problem accessing the ecCodes library. "
28+
"Try `import cfgrib` to get the full error message"
2829
)
2930
has_cfgrib = False
3031

0 commit comments

Comments
 (0)