executeGuarded method
void
executeGuarded()
Runs generateDocs function and properly handles the errors.
Implementation
void executeGuarded() {
onCheckProgress.listen(logProgress);
// This function should *never* `await runZonedGuarded` because the errors
// thrown in [generateDocs] are uncaught. We want this because uncaught
// errors cause IDE debugger to automatically stop at the exception.
//
// If you await the zone, the code that comes after the await is not
// executed if the zone dies due to an uncaught error. To avoid this,
// confusion, never `await runZonedGuarded`.
runZonedGuarded(
() async {
runtimeStats.startPerfTask('generateDocs');
await generateDocs();
runtimeStats.endPerfTask();
},
(e, stackTrace) {
stderr.writeln('\n$_dartdocFailedMessage: $e\n$stackTrace');
exitCode = e is DartdocFailure ? 1 : 255;
},
zoneSpecification: ZoneSpecification(
print: (_, __, ___, String line) => logInfo(line),
),
);
}