From a9fdff244aef859449a76e5f762ee7c343a8ddcc Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 10 Mar 2023 20:47:23 +0100 Subject: Expose content representation more --- library/src/compute/foundations.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'library/src/compute') diff --git a/library/src/compute/foundations.rs b/library/src/compute/foundations.rs index 41a6bc35..8b148c85 100644 --- a/library/src/compute/foundations.rs +++ b/library/src/compute/foundations.rs @@ -53,7 +53,7 @@ pub fn repr( /// Fail with an error. /// /// ## Example -/// The code below produces the error `panicked at: "this is wrong"`. +/// The code below produces the error `panicked with: "this is wrong"`. /// ```typ /// #panic("this is wrong") /// ``` @@ -63,14 +63,21 @@ pub fn repr( /// Returns: #[func] pub fn panic( - /// The value (or message) to panic with. - #[default] - payload: Option, + /// The values to panic with. + #[variadic] + values: Vec, ) -> Value { - match payload { - Some(v) => bail!(args.span, "panicked with: {}", v.repr()), - None => bail!(args.span, "panicked"), + let mut msg = EcoString::from("panicked"); + if !values.is_empty() { + msg.push_str(" with: "); + for (i, value) in values.iter().enumerate() { + if i > 0 { + msg.push_str(", "); + } + msg.push_str(&value.repr()); + } } + bail!(args.span, msg); } /// Ensure that a condition is fulfilled. -- cgit v1.2.3