From: <rob...@us...> - 2010-08-18 05:07:44
|
Revision: 82 http://netcdftools.svn.sourceforge.net/netcdftools/?rev=82&view=rev Author: robertbridle Date: 2010-08-18 05:07:38 +0000 (Wed, 18 Aug 2010) Log Message: ----------- ANDSWRON-290 - Caught NullPointerException when an invalid variable is specified on the command line. We now throw an InvalidArgumentException instead. Modified Paths: -------------- trunk/src/main/java/au/csiro/netcdf/NcWriteVariable.java Modified: trunk/src/main/java/au/csiro/netcdf/NcWriteVariable.java =================================================================== --- trunk/src/main/java/au/csiro/netcdf/NcWriteVariable.java 2010-08-16 07:40:34 UTC (rev 81) +++ trunk/src/main/java/au/csiro/netcdf/NcWriteVariable.java 2010-08-18 05:07:38 UTC (rev 82) @@ -172,6 +172,14 @@ try { Variable variable = ncfile.findVariable(NetcdfFile.escapeName(variableName)); + + // Check the variable exists + if (variable == null) + { + throw new IllegalArgumentException("The variable: " + variableName + " does not exist in the file: " + + ncfile.getLocation()); + } + List<Range> ranges = variable.getRanges(); // Check the ranges match @@ -224,7 +232,6 @@ { ncfile.close(); } - } /* (non-Javadoc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |