From 1619aa83220e9e509af20ec84c324e08a046ace8 Mon Sep 17 00:00:00 2001 From: Katherine Kiefer Date: Thu, 6 Jun 2024 22:38:56 +1000 Subject: [PATCH] add a proper message lol --- crates/byondapi-macros/src/lib.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/byondapi-macros/src/lib.rs b/crates/byondapi-macros/src/lib.rs index f2f6cb2..5d36f1a 100644 --- a/crates/byondapi-macros/src/lib.rs +++ b/crates/byondapi-macros/src/lib.rs @@ -130,7 +130,13 @@ pub fn bind(attr: TokenStream, item: TokenStream) -> TokenStream { Ok(val) => val, Err(e) => { let error_string = ::byondapi::value::ByondValue::try_from(::std::format!("{e:?}")).unwrap(); - ::byondapi::global_call::call_global_id(byond_string!("stack_trace"), &[error_string]).unwrap(); + ::byondapi::global_call::call_global_id({ + static STACK_TRACE: ::std::sync::OnceLock = ::std::sync::OnceLock::new(); + *STACK_TRACE.get_or_init(|| ::byondapi::byond_string::str_id_of("stack_trace") + .expect("byondapi-rs implicitly expects stack_trace to exist as a proc for error reporting purposes, this proc doesn't exist!") + ) + } + ,&[error_string]).unwrap(); ::byondapi::value::ByondValue::null() } } @@ -232,7 +238,13 @@ pub fn bind_raw_args(attr: TokenStream, item: TokenStream) -> TokenStream { Ok(val) => val, Err(e) => { let error_string = ::byondapi::value::ByondValue::try_from(::std::format!("{e:?}")).unwrap(); - ::byondapi::global_call::call_global_id(byond_string!("stack_trace"), &[error_string]).unwrap(); + ::byondapi::global_call::call_global_id({ + static STACK_TRACE: ::std::sync::OnceLock = ::std::sync::OnceLock::new(); + *STACK_TRACE.get_or_init(|| ::byondapi::byond_string::str_id_of("stack_trace") + .expect("byondapi-rs implicitly expects stack_trace to exist as a proc for error reporting purposes, this proc doesn't exist!") + ) + } + ,&[error_string]).unwrap(); ::byondapi::value::ByondValue::null() } }