From 94ec3e014dfb3a7e6d5727fa02bef628b76de65b Mon Sep 17 00:00:00 2001 From: Simon Poltier Date: Wed, 7 Aug 2024 08:56:23 +0200 Subject: [PATCH] confusing warning when checking if name exists (#38) --- src/main/java/com/miraisolutions/xlconnect/Workbook.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/miraisolutions/xlconnect/Workbook.java b/src/main/java/com/miraisolutions/xlconnect/Workbook.java index 72fa6d9..02b35ab 100644 --- a/src/main/java/com/miraisolutions/xlconnect/Workbook.java +++ b/src/main/java/com/miraisolutions/xlconnect/Workbook.java @@ -276,7 +276,6 @@ public ResultWithAttributes existsName(String name, String worksheetSco String foundInScope = effectiveScope(worksheetScope, found); return new ResultWithAttributes(true, WORKSHEET_SCOPE, foundInScope); } catch (IllegalArgumentException ignored) { - warnings.add(ignored.getMessage()); return worksheetScope != null ? new ResultWithAttributes(false, WORKSHEET_SCOPE, worksheetScope) : new ResultWithAttributes(false); } @@ -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