summaryrefslogtreecommitdiff
path: root/library/src/compute
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-10 20:47:23 +0100
committerLaurenz <laurmaedje@gmail.com>2023-03-10 21:19:50 +0100
commita9fdff244aef859449a76e5f762ee7c343a8ddcc (patch)
tree172b543183296b4bc30b3008650f594688467914 /library/src/compute
parent62f35602a87574dcc607f1637aeae1be574981ff (diff)
Expose content representation more
Diffstat (limited to 'library/src/compute')
-rw-r--r--library/src/compute/foundations.rs21
1 files changed, 14 insertions, 7 deletions
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<Value>,
+ /// The values to panic with.
+ #[variadic]
+ values: Vec<Value>,
) -> 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.