Skip to content

Commit 03a4bf5

Browse files
authored
Merge pull request #824 from HubSpot/fix-no-such-element
Prevent NoSuchElementException when adding error
2 parents 419b938 + 79b7f50 commit 03a4bf5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/main/java/com/hubspot/jinjava/interpret/JinjavaInterpreter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,10 @@ public void addError(TemplateError templateError) {
694694
}
695695
// fix line numbers not matching up with source template
696696
if (!context.getCurrentPathStack().isEmpty()) {
697-
if (!templateError.getSourceTemplate().isPresent()) {
697+
if (
698+
!templateError.getSourceTemplate().isPresent() &&
699+
context.getCurrentPathStack().peek().isPresent()
700+
) {
698701
templateError.setMessage(
699702
getWrappedErrorMessage(
700703
context.getCurrentPathStack().peek().get(),

0 commit comments

Comments
 (0)