Rename private cleanup and error handlers to public

Renamed the internal _cleanup and _handleError functions to cleanup and handleError, respectively, and updated all references.
This commit is contained in:
Ankit Mahato
2025-06-29 06:45:46 +05:30
parent 9735ed655d
commit 51cfccb555

View File

@ -176,14 +176,14 @@ Future<Stream<(String?, Duration?, String?)?>> streamHttpRequest(
StreamSubscription<String?>? subscription;
final stopwatch = Stopwatch()..start();
_cleanup() async {
cleanup() async {
stopwatch.stop();
httpClientManager.closeClient(requestId);
await Future.microtask(() {});
controller.close();
}
Future<void> _handleError(dynamic error) async {
Future<void> handleError(dynamic error) async {
await Future.microtask(() {});
if (httpClientManager.wasRequestCancelled(requestId)) {
controller.add((null, null, kMsgRequestCancelled));
@ -191,7 +191,7 @@ Future<Stream<(String?, Duration?, String?)?>> streamHttpRequest(
} else {
controller.add((null, null, error.toString()));
}
await _cleanup();
await cleanup();
}
controller.onCancel = () async {
@ -214,7 +214,7 @@ Future<Stream<(String?, Duration?, String?)?>> streamHttpRequest(
);
if (uri == null) {
await _handleError(uriError ?? 'Invalid URL');
await handleError(uriError ?? 'Invalid URL');
return controller.stream;
}
@ -245,8 +245,8 @@ Future<Stream<(String?, Duration?, String?)?>> streamHttpRequest(
subscription = stream.listen(
(data) => controller.add((data, stopwatch.elapsed, null)),
onDone: () => _cleanup(),
onError: _handleError,
onDone: () => cleanup(),
onError: handleError,
);
return controller.stream;
@ -282,13 +282,13 @@ Future<Stream<(String?, Duration?, String?)?>> streamHttpRequest(
controller.add((data, stopwatch.elapsed, null));
}
},
onDone: () => _cleanup(),
onError: _handleError,
onDone: () => cleanup(),
onError: handleError,
);
return controller.stream;
} catch (e) {
await _handleError(e);
await handleError(e);
return controller.stream;
}
}