Skip to content

Commit 766ad9c

Browse files
committed
better msg
1 parent 0ecb751 commit 766ad9c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/test/java/org/primeframework/mvc/test/BodyTools.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ public static String processTemplateWithMap(Path path, DetectionMap values, bool
106106
Set<Object> unusedVariables = values.getUnusedVariables("_",
107107
"actual");
108108
if (!unusedVariables.isEmpty()) {
109-
throw new IllegalArgumentException("The following variables are not used in the [%s] template: %s".formatted(path,
110-
unusedVariables.stream()
111-
.sorted()
112-
.toList()));
109+
throw new IllegalArgumentException("Variables %s are not used in the [%s] template. If it's acceptable for the variable to not be used, wrap it in an Optional".formatted(unusedVariables.stream()
110+
.sorted()
111+
.toList(),
112+
path));
113113
}
114114
return writer.toString();
115115
} catch (TemplateException e) {

src/test/java/org/primeframework/mvc/test/BodyToolsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void processTemplateWithMap_unused_variables() throws Exception {
101101
} catch (Exception e) {
102102
assertEquals(e.getClass(), IllegalArgumentException.class,
103103
"Expected this exception type");
104-
assertEquals(e.getMessage(), "The following variables are not used in the [src/test/web/templates/echo.ftl] template: [othervariable]",
104+
assertEquals(e.getMessage(), "Variables [othervariable] are not used in the [src/test/web/templates/echo.ftl] template. If it's acceptable for the variable to not be used, wrap it in an Optional",
105105
"othervariable is in the map but is not used");
106106
}
107107
}

0 commit comments

Comments
 (0)