From 91e3c88d8f6428d41326869bbd8f6ece99145627 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sat, 1 Jul 2023 15:44:04 +0200 Subject: derive: define separate ParseError type --- askama_derive/src/generator.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'askama_derive/src/generator.rs') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index f8b9ecb..f17b6f6 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -259,7 +259,11 @@ mod _parsed { // internally we will transmute it to `&'static str` to satisfy the compiler. // However, we only expose the nodes with a lifetime limited to `self`. let src = unsafe { mem::transmute::<&str, &'static str>(source.as_str()) }; - let nodes = parse(src, syntax)?; + let nodes = match parse(src, syntax) { + Ok(nodes) => nodes, + Err(e) => return Err(e.to_string().into()), + }; + Ok(Self { source, nodes }) } -- cgit