You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// access to the state of the execution to influence scheduling (e.g. to register a task as
388
397
/// blocked).
389
398
#[inline]
399
+
#[track_caller]
390
400
pub(crate)fnwith<F,T>(f:F) -> T
391
401
where
392
402
F:FnOnce(&mutExecutionState) -> T,
393
403
{
394
-
Self::try_with(f).expect("Shuttle internal error: cannot access ExecutionState. are you trying to access a Shuttle primitive from outside a Shuttle test?")
404
+
Self::try_with(f).unwrap_or_else(|e| {
405
+
eprintln!("`ExecutionState::try_with` failed with error: {e:?}");
406
+
eprintln!(
407
+
"Backtrace for `with`: {:#?}",
408
+
std::backtrace::Backtrace::force_capture()
409
+
);
410
+
match e {
411
+
ExecutionStateBorrowError::AlreadyBorrowed => panic!("`ExecutionState::with` panicked because `ExecutionState` is already borrowed."),
412
+
ExecutionStateBorrowError::NotSet => panic!("`ExecutionState::with` panicked because `ExecutionState` is not set. Are you accessing a Shuttle primitive outside of a Shuttle test?"),
413
+
}
414
+
})
395
415
}
396
416
397
417
/// Like `with`, but returns None instead of panicking if there is no current ExecutionState or
398
418
/// if the current ExecutionState is already borrowed.
0 commit comments