reportSuiteEndWithStorageRestore function

void reportSuiteEndWithStorageRestore({
  1. Object? suiteError,
  2. StackTrace? suiteStackTrace,
  3. Object? storageRestoreError,
})

Surfaces storage-restore failures as suite infrastructure failures.

Preserves suiteError when present and appends the restore failure so both are visible; a restore-only failure fails the suite with a clear message.

Implementation

void reportSuiteEndWithStorageRestore({
  Object? suiteError,
  StackTrace? suiteStackTrace,
  Object? storageRestoreError,
}) {
  if (storageRestoreError != null && suiteError != null) {
    fail(
      '${_formatSuiteError(suiteError)}\n\n'
      'Also failed to restore pre-suite device storage: $storageRestoreError',
    );
  }
  if (storageRestoreError != null) {
    fail(
      'Failed to restore pre-suite device storage after the suite: '
      '$storageRestoreError',
    );
  }
  if (suiteError != null) {
    if (suiteStackTrace != null) {
      Error.throwWithStackTrace(suiteError, suiteStackTrace);
    }
    throw suiteError;
  }
}