runRestorePhases static method
Runs clear then rewrite, wrapping failures with a phase-named StateError.
Implementation
@visibleForTesting
static Future<void> runRestorePhases({
required Future<void> Function() clear,
required Future<void> Function() rewrite,
}) async {
return await RunnerBenchmark.async('lifecycle', 'runRestorePhases',
() async {
try {
await clear();
} catch (error, stackTrace) {
Error.throwWithStackTrace(
StateError(
'AppSessionSnapshot restore failed during clear phase: $error',
),
stackTrace,
);
}
try {
await rewrite();
} catch (error, stackTrace) {
Error.throwWithStackTrace(
StateError(
'AppSessionSnapshot restore failed during rewrite phase: $error',
),
stackTrace,
);
}
});
}