Skip to content

Commit

Permalink
confusing warning when checking if name exists (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
spoltier authored Aug 7, 2024
1 parent a19534e commit 94ec3e0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/com/miraisolutions/xlconnect/Workbook.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ public ResultWithAttributes<Boolean> existsName(String name, String worksheetSco
String foundInScope = effectiveScope(worksheetScope, found);
return new ResultWithAttributes<Boolean>(true, WORKSHEET_SCOPE, foundInScope);
} catch (IllegalArgumentException ignored) {
warnings.add(ignored.getMessage());
return worksheetScope != null ? new ResultWithAttributes<Boolean>(false, WORKSHEET_SCOPE, worksheetScope)
: new ResultWithAttributes<Boolean>(false);
}
Expand Down Expand Up @@ -995,12 +994,12 @@ private Name getName(String name, String worksheetScope) {
StringBuffer names = new StringBuffer();
String worksheetScopeDisplay = displayWorksheetScope(worksheetScope);
cNames.forEach(n -> names.append(n.getSheetIndex() >= 0 ? workbook.getSheetName(n.getSheetIndex()) : "global scope").append(";"));
throw new IllegalArgumentException("Name '" + name + "' was not specified '" + worksheetScopeDisplay + "'! " +
throw new IllegalArgumentException("Name '" + name + "' was not specified " + worksheetScopeDisplay + "! " +
"Found in sheets: " + names);
}

private String displayWorksheetScope(String worksheetScope) {
return null == worksheetScope ? "" : worksheetScope.isEmpty() ? "in global scope" : "in " +worksheetScope;
return null == worksheetScope ? "" : worksheetScope.isEmpty() ? "in global scope" : "in '" +worksheetScope+ "'";
}

// Checks only if the reference as such is valid
Expand Down

0 comments on commit 94ec3e0

Please sign in to comment.