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:
- AsyncPhase.rethrowIfError, a method that calls AsyncError.rethrowError only when the phase is an AsyncError, and does nothing otherwise.
Implementation
Never rethrowError() {
return Error.throwWithStackTrace(error, stackTrace);
}