diff --git a/pkgs/cupertino_http/CHANGELOG.md b/pkgs/cupertino_http/CHANGELOG.md index b93aac4c2a..c0ece78d55 100644 --- a/pkgs/cupertino_http/CHANGELOG.md +++ b/pkgs/cupertino_http/CHANGELOG.md @@ -1,7 +1,8 @@ ## 2.4.0-wip * Switch to `package:objective_c` `8.1.0` and `package:ffigen` `19.1.0`. - +* Add URL to thrown `RequestAbortedException`. + ## 2.3.0 * Add the ability to abort requests. diff --git a/pkgs/cupertino_http/lib/src/cupertino_client.dart b/pkgs/cupertino_http/lib/src/cupertino_client.dart index 39adcae25c..5a4110ac81 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_client.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_client.dart @@ -207,6 +207,9 @@ class CupertinoClient extends BaseClient { // 2. The user aborts the request, which can happen at any point in the // request lifecycle and causes `CupertinoClient.send` to throw // a `RequestAbortedException` exception. + // + // In both of these cases [URLSessionTask.cancel] is called, which completes + // the task with a NSURLErrorCancelled error. final isCancelError = error?.domain.toDartString() == 'NSURLErrorDomain' && error?.code == _nsurlErrorCancelled; @@ -214,7 +217,8 @@ class CupertinoClient extends BaseClient { !(isCancelError && taskTracker.responseListenerCancelled)) { final Exception exception; if (isCancelError) { - exception = RequestAbortedException(); + assert(taskTracker.requestAborted); + exception = RequestAbortedException(taskTracker.request.url); } else { exception = NSErrorClientException(error, taskTracker.request.url); }