Repository: climate Updated Branches: refs/heads/master 227b5de93 -> 8d3ab4eae
CLIMATE-487 - Improve error message when local dataset load fails - Explicit RuntimeErrors are not properly handled to alert the user that the supplied file path is invalid. This helps clarify user controllable failures. - Attempt to make the generic error on dataset loading a bit more descriptive to help users. Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/c5a694dc Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/c5a694dc Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/c5a694dc Branch: refs/heads/master Commit: c5a694dcb0d01b57be69788b4762afa87a5c8f6b Parents: 227b5de Author: Michael Joyce <[email protected]> Authored: Fri Nov 7 13:49:04 2014 -0800 Committer: Michael Joyce <[email protected]> Committed: Fri Nov 7 13:49:04 2014 -0800 ---------------------------------------------------------------------- ocw/data_source/local.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/c5a694dc/ocw/data_source/local.py ---------------------------------------------------------------------- diff --git a/ocw/data_source/local.py b/ocw/data_source/local.py index 0cbecad..384a781 100644 --- a/ocw/data_source/local.py +++ b/ocw/data_source/local.py @@ -134,10 +134,14 @@ def load_file(file_path, variable_name, elevation_index=0): try: netcdf = netCDF4.Dataset(file_path, mode='r') + except RuntimeError: + err = "Dataset filepath is invalid. Please ensure it is correct." + raise ValueError(err) except: err = ( - "The given file cannot be loaded " - "(Only NetCDF file can be supported)." + "The given file cannot be loaded. Please ensure that it is a valid " + "NetCDF file. If problems persist, report them to the project's " + "mailing list." ) raise ValueError(err)
