Skip to content

Commit 54dfd63

Browse files
authored
docs(cupertino_http): Clarify that happens when a request is cancelled (#1834)
1 parent 3e3c366 commit 54dfd63

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkgs/cupertino_http/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## 2.4.0-wip
22

33
* Switch to `package:objective_c` `8.1.0` and `package:ffigen` `19.1.0`.
4-
4+
* Add URL to thrown `RequestAbortedException`.
5+
56
## 2.3.0
67

78
* Add the ability to abort requests.

pkgs/cupertino_http/lib/src/cupertino_client.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,18 @@ class CupertinoClient extends BaseClient {
207207
// 2. The user aborts the request, which can happen at any point in the
208208
// request lifecycle and causes `CupertinoClient.send` to throw
209209
// a `RequestAbortedException` exception.
210+
//
211+
// In both of these cases [URLSessionTask.cancel] is called, which completes
212+
// the task with a NSURLErrorCancelled error.
210213
final isCancelError =
211214
error?.domain.toDartString() == 'NSURLErrorDomain' &&
212215
error?.code == _nsurlErrorCancelled;
213216
if (error != null &&
214217
!(isCancelError && taskTracker.responseListenerCancelled)) {
215218
final Exception exception;
216219
if (isCancelError) {
217-
exception = RequestAbortedException();
220+
assert(taskTracker.requestAborted);
221+
exception = RequestAbortedException(taskTracker.request.url);
218222
} else {
219223
exception = NSErrorClientException(error, taskTracker.request.url);
220224
}

0 commit comments

Comments
 (0)