Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit e1c6cd5

Browse files
committed
wip: better error
1 parent 69c4bf8 commit e1c6cd5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

askama_parser/src/expr.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,22 @@ impl<'a> Expr<'a> {
200200
Ok((i, (fname, args)))
201201
}
202202

203-
let (i, (obj, filters)) = tuple((
203+
let result = tuple((
204204
|i| Self::prefix(i, level),
205205
many_m_n(0, 16, |i| filter(i, level)),
206-
))(i)?;
206+
))(i);
207+
208+
let (i, (obj, filters)) = match result {
209+
Ok((i, (obj, filters))) => (i, (obj, filters)),
210+
Err(nom::Err::Error(err)) if dbg!(err.kind) == ErrorKind::ManyMN => {
211+
return Err(nom::Err::Failure(ErrorContext {
212+
input: i,
213+
message: Some(Cow::Borrowed("too many nested filters")),
214+
kind: ErrorKind::ManyMN,
215+
}))
216+
}
217+
Err(e) => return Err(e),
218+
};
207219

208220
let mut res = obj;
209221
for (fname, args) in filters {

0 commit comments

Comments
 (0)