Function Reactor.throwInFiber

forward an exception to another fiber

bool throwInFiber (
  FiberHandle fHandle,
  object.Throwable ex
) nothrow @nogc @safe;

bool throwInFiber(T, string file = __FILE_FULL_PATH__, ulong line = __LINE__, A...) (
  FiberHandle fHandle,
  auto ref A args
) nothrow @nogc @safe;

This function throws an exception in another fiber. The fiber will be scheduled to run.

There is a difference in semantics between the two forms. The first form throws an identical copy of the exception in the target fiber. The second form forms a new exception to be thrown in that fiber.

One place where this difference matters is with the stack trace the thrown exception will have. With the first form, the stack trace will be the stack trace ex has, wherever it is (usually not in the fiber in which the exception was thrown). With the second form, the stack trace will be of the target fiber, which means it will point back to where the fiber went to sleep.