run method
Runs the check once and returns the final CheckInfo.
Implementation
Future<CheckInfo> run() async {
if (status != CheckStatus.idle) {
throw StateError('check is running already');
}
setStatus(CheckStatus.running);
try {
await perform();
} catch (err) {
if (options.errorsAsWarnings) {
appendWarning(messageFor(err));
} else {
appendError(messageFor(err));
}
}
try {
await disconnect();
} catch (err) {
// don't let a failing disconnect (e.g. after a connect that failed
// mid-handshake) prevent the check from reporting its result
appendWarning('failed to disconnect: ${messageFor(err)}');
}
// sleep for a bit to ensure disconnect
await Future<void>.delayed(const Duration(milliseconds: 500));
if (status != CheckStatus.skipped) {
setStatus(isSuccess() ? CheckStatus.success : CheckStatus.failed);
}
return getInfo();
}