rethrowError method

Never rethrowError()

A utility method that just wraps Error.throwWithStackTrace.

This is useful when it is necessary to rethrow the error this AsyncError object has with associated stack trace.

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

See also:

Implementation

Never rethrowError() {
  return Error.throwWithStackTrace(error, stackTrace);
}