more specific exception instead of NPE

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892951 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2021-09-05 19:05:54 +00:00
parent 89d37d2936
commit 0bb651955e
1 changed files with 5 additions and 2 deletions

View File

@ -210,7 +210,6 @@ public final class OperationEvaluationContext {
}
SheetRangeEvaluator sre = new SheetRangeEvaluator(_sheetIndex, se);
// ugly typecast - TODO - make spreadsheet version more easily accessible
SpreadsheetVersion ssVersion = _workbook.getSpreadsheetVersion();
NameType part1refType = classifyCellReference(refStrPart1, ssVersion);
@ -219,6 +218,10 @@ public final class OperationEvaluationContext {
return ErrorEval.REF_INVALID;
case NAMED_RANGE:
EvaluationName nm = _workbook.getName(refStrPart1, _sheetIndex);
if(nm == null) {
throw new RuntimeException("Specified name '" + refStrPart1 +
"' is not found in the workbook (sheetIndex=" + _sheetIndex +").");
}
if(!nm.isRange()) {
throw new RuntimeException("Specified name '" + refStrPart1 + "' is not a range as expected.");
}