From 8881b8a47386029a7de048185bcfc88e58dfe3a8 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Thu, 11 Jan 2024 11:37:12 -0800 Subject: [PATCH] Use error instead of panic for span location in rsx macro shorthand --- packages/rsx/src/element.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/rsx/src/element.rs b/packages/rsx/src/element.rs index ff398f7d3..b3fb3cf4f 100644 --- a/packages/rsx/src/element.rs +++ b/packages/rsx/src/element.rs @@ -140,7 +140,17 @@ impl Parse for Element { // If the shorthand field is children, these are actually children! if name == "children" { - panic!("children must be wrapped in braces"); + return Err(syn::Error::new( + name.span(), + format!( + r#"Shorthand element children are not supported. +To pass children into elements, wrap them in curly braces. +Like so: + div {{ {{children}} }} + +"#, + ), + )); }; let value = ElementAttrValue::Shorthand(name.clone());