       XCTFail("succeeded incorrectly")
     }
     catch let error as URLError {
+      XCTAssertEqual(error.code, .cancelled)
+    }
+    catch URLSessionError.InterruptedDownload(let error, _) {
       XCTAssertEqual(error.code, .cancelled)
     }
 

    catch let error as URLError {
      XCTAssertEqual(error.code, .cancelled)
    }

    session.finishTasksAndInvalidate()
  }

  func testDownload_DoubleCancellation() throws
  {
    let deferred: DeferredURLSessionTask<(URL, FileHandle, HTTPURLResponse)> = {
      let url = URL(string: "http://127.0.0.1:65521/image.jpg")!
      let session = URLSession(configuration: .default)
      defer { session.finishTasksAndInvalidate() }

