run method

void run(
  1. DartBlockArbiter arbiter
)

Execute the Statement, using the given DartBlockArbiter.

Implementation

void run(DartBlockArbiter arbiter) {
  try {
    _execute(arbiter);
  } on DartBlockException catch (neoTechException) {
    /// Designate this [Statement] as the cause of the thrown [DartBlockException].
    neoTechException.statement ??= this;
    rethrow;
  } on ReturnStatementException {
    /// CRITICAL: [ReturnStatementException] is a special class used to propagate the return value in the body of a [DartBlockFunction].
    /// Simply rethrow it to move it up the stack.
    rethrow;
  } on Exception catch (ex) {
    // A common Dart Exception not known by DartBlock: we wrap it in our own [DartBlockException].
    throw DartBlockException.fromException(exception: ex, statement: this);
  } on StackOverflowError catch (_) {
    // Thrown by Dart, e.g., in the case of a faulty recursive function call (missing ending condition).
    throw DartBlockException(
      title: "Stack Overflow",
      message:
          "The program was killed due to a stack overflow error. This can occur if you have a recursive function without an appropriate ending condition.",
      statement: this,
    );
  } on Error catch (err) {
    // Very generic error thrown by Dart: we wrap it in our own [DartBlockException].
    if (kDebugMode) {
      print(err);
    }
    throw DartBlockException(
      title: "Critical Error",
      message:
          "The program was killed due to an unknown error. Ensure your program does not contain an infinite loop or a recursive function without an ending condition!",
      statement: this,
    );
  }
}