Skip to content

Commit bd36c4b

Browse files
authored
Merge pull request #29 from GuillaumeGomez/improve-ui-error
Improve error message in case too much nesting
2 parents 704c506 + 1f1cff0 commit bd36c4b

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

rinja_parser/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,10 @@ pub(crate) struct Level(u8);
711711
impl Level {
712712
fn nest(self, i: &str) -> ParseResult<'_, Level> {
713713
if self.0 >= Self::MAX_DEPTH {
714-
return Err(ErrorContext::from_err(nom::Err::Failure(error_position!(
714+
return Err(nom::Err::Failure(ErrorContext::new(
715+
"your template code is too deeply nested, or last expression is too complex",
715716
i,
716-
ErrorKind::TooLarge
717-
))));
717+
)));
718718
}
719719

720720
Ok((i, Level(self.0 + 1)))

testing/tests/ui/excessive_nesting.stderr

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
error: failed to parse template source at row 14, column 42 near:
1+
error: your template code is too deeply nested, or last expression is too complex
2+
failed to parse template source at row 14, column 42 near:
23
"%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1"...
34
--> tests/ui/excessive_nesting.rs:3:10
45
|

testing/tests/ui/filter-recursion.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
error: failed to parse template source
2-
--> testing/templates/filter-recursion.html:1:255
1+
error: your template code is too deeply nested, or last expression is too complex
2+
failed to parse template source
3+
--> testing/templates/filter-recursion.html:1:255
34
"|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A"...
45
--> tests/ui/filter-recursion.rs:3:10
56
|

0 commit comments

Comments
 (0)