Skip to content

Commit 79b7f50

Browse files
committed
Prevent NoSuchElementException when adding error
1 parent 419b938 commit 79b7f50

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)