ifSync method
Performs a side-effect if this is Sync.
Implementation
@override
@pragma('vm:prefer-inline')
Sync<T> ifSync(
@noFutures void Function(Sync<T> self, Sync<T> sync) noFutures,
) {
// Side-effect path: an absorbed throw from the callback must surface as an
// Err on the returned Sync. `on Err catch` preserves a user-thrown `Err`
// verbatim — wrapping it would lose statusCode/breadcrumbs/stackTrace.
try {
noFutures(this, this);
return this;
} on Err catch (err) {
return Sync.err(err.transfErr<T>());
} catch (error, stackTrace) {
return Sync.err(Err<T>(error, stackTrace: stackTrace));
}
}