runSync method

R runSync()

{@category execution}

Implementation

R runSync() {
  try {
    final result = _unsafeRun(Context.env(null));
    if (result is Future) {
      throw Die.current(
        Exception("runSync cannot execute async Effect"),
      );
    }

    return switch (result) {
      Left(value: final cause) => throw cause,
      Right(value: final value) => value,
    };
  } on Cause<L> {
    rethrow;
  } catch (error, stackTrace) {
    throw Die(error, stackTrace);
  }
}