run method
Execute the Statement, using the given DartBlockArbiter.
Implementation
@override
T? run(DartBlockArbiter arbiter) {
// The body of this run override is identical to the super's method body (Statement),
// except here run() has a non-void return type T?, requiring the statement
// 'return _execute(arbiter);' instead!
try {
return _execute(arbiter);
} on DartBlockException catch (neoTechException) {
neoTechException.statement ??= this;
rethrow;
} on ReturnStatementException {
/// IMPORTANT: End the block, as the error being thrown causes the endBlock call
/// to never be reached inside _execute!!!!
arbiter.endScope(_lastExecutionCode);
/// Do not do anything here!! ReturnStatementException is a very special
/// type used to propagate a return value in a function's body.
rethrow;
} on Exception catch (ex) {
throw DartBlockException.fromException(exception: ex, statement: this);
} on StackOverflowError catch (_) {
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) {
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,
);
}
}