rethrowIfError method

void rethrowIfError()

A method that rethrows the error if this AsyncPhase instance is of type AsyncError.

This calls AsyncError.rethrowError only when appropriate. It returns normally (i.e., does nothing) if the phase is not an AsyncError.

Future<AsyncPhase<Uint8List>> fetchImage({required Uri uri}) async {
  return AsyncPhase.from(() {
    final phase = await downloadFrom(uri: uri);
    phase.rethrowIfError();
    return resizeImage(phase.data, maxSize: ...);
  });
}

Implementation

void rethrowIfError() {
  // no-op
}