@@ -262,7 +262,7 @@ where
262
262
godot_error ! ( "{message}" ) ;
263
263
}
264
264
eprintln ! ( "{message}" ) ;
265
- #[ cfg( debug_assertions) ]
265
+ #[ cfg( debug_assertions) ] // TODO: remove too?
266
266
eprintln ! ( "{}" , std:: backtrace:: Backtrace :: capture( ) ) ;
267
267
let _ignored_result = std:: io:: stderr ( ) . flush ( ) ;
268
268
} ) ) ;
@@ -281,12 +281,12 @@ pub(crate) fn has_error_print_level(level: u8) -> bool {
281
281
/// Internal type used to store context information for debug purposes. Debug context is stored on the thread-local
282
282
/// ERROR_CONTEXT_STACK, which can later be used to retrieve the current context in the event of a panic. This value
283
283
/// probably shouldn't be used directly; use ['get_gdext_panic_context()'](get_gdext_panic_context) instead.
284
- #[ cfg( debug_assertions) ]
284
+ #[ cfg( all ( debug_assertions, not ( wasm_nothreads ) ) ) ]
285
285
struct ScopedFunctionStack {
286
286
functions : Vec < * const dyn Fn ( ) -> String > ,
287
287
}
288
288
289
- #[ cfg( debug_assertions) ]
289
+ #[ cfg( all ( debug_assertions, not ( wasm_nothreads ) ) ) ]
290
290
impl ScopedFunctionStack {
291
291
/// # Safety
292
292
/// Function must be removed (using [`pop_function()`](Self::pop_function)) before lifetime is invalidated.
@@ -311,7 +311,7 @@ impl ScopedFunctionStack {
311
311
}
312
312
}
313
313
314
- #[ cfg( debug_assertions) ]
314
+ #[ cfg( all ( debug_assertions, not ( wasm_nothreads ) ) ) ]
315
315
thread_local ! {
316
316
static ERROR_CONTEXT_STACK : RefCell <ScopedFunctionStack > = const {
317
317
RefCell :: new( ScopedFunctionStack { functions: Vec :: new( ) } )
@@ -320,9 +320,9 @@ thread_local! {
320
320
321
321
// Value may return `None`, even from panic hook, if called from a non-Godot thread.
322
322
pub fn get_gdext_panic_context ( ) -> Option < String > {
323
- #[ cfg( debug_assertions) ]
323
+ #[ cfg( all ( debug_assertions, not ( wasm_nothreads ) ) ) ]
324
324
return ERROR_CONTEXT_STACK . with ( |cell| cell. borrow ( ) . get_last ( ) ) ;
325
- #[ cfg( not( debug_assertions) ) ]
325
+ #[ cfg( not( all ( debug_assertions, not ( wasm_nothreads ) ) ) ) ]
326
326
None
327
327
}
328
328
@@ -337,14 +337,14 @@ where
337
337
E : Fn ( ) -> String ,
338
338
F : FnOnce ( ) -> R + std:: panic:: UnwindSafe ,
339
339
{
340
- #[ cfg( debug_assertions) ]
340
+ #[ cfg( all ( debug_assertions, not ( wasm_nothreads ) ) ) ]
341
341
ERROR_CONTEXT_STACK . with ( |cell| unsafe {
342
342
// SAFETY: &error_context is valid for lifetime of function, and is removed from LAST_ERROR_CONTEXT before end of function.
343
343
cell. borrow_mut ( ) . push_function ( & error_context)
344
344
} ) ;
345
345
let result =
346
346
std:: panic:: catch_unwind ( code) . map_err ( |payload| extract_panic_message ( payload. as_ref ( ) ) ) ;
347
- #[ cfg( debug_assertions) ]
347
+ #[ cfg( all ( debug_assertions, not ( wasm_nothreads ) ) ) ]
348
348
ERROR_CONTEXT_STACK . with ( |cell| cell. borrow_mut ( ) . pop_function ( ) ) ;
349
349
result
350
350
}
0 commit comments