@@ -891,24 +891,16 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
891891 // ignore: lines_longer_than_80_chars
892892 (nsSession, nsTask, nsResponse, nsRequest, nsRequestCompleter) {
893893 final request = URLRequest ._(nsRequest);
894- URLRequest ? redirectRequest;
895-
896- try {
897- final response =
898- URLResponse ._exactURLResponseType (nsResponse)
899- as HTTPURLResponse ;
900- redirectRequest = onRedirect (
901- URLSession ._(nsSession, isBackground: isBackground),
902- URLSessionTask ._(nsTask),
903- response,
904- request,
905- );
906- nsRequestCompleter.call (redirectRequest? ._nsObject);
907- } catch (e) {
908- // TODO(https://github.com/dart-lang/ffigen/issues/386): Package
909- // this exception as an `Error` and call the completion function
910- // with it.
911- }
894+ final response =
895+ URLResponse ._exactURLResponseType (nsResponse)
896+ as HTTPURLResponse ;
897+ final redirectRequest = onRedirect (
898+ URLSession ._(nsSession, isBackground: isBackground),
899+ URLSessionTask ._(nsTask),
900+ response,
901+ request,
902+ );
903+ nsRequestCompleter.call (redirectRequest? ._nsObject);
912904 },
913905 );
914906 }
@@ -1009,14 +1001,15 @@ class URLSession extends _ObjectHolder<ncb.NSURLSession> {
10091001 /// a follow-up request that would honor the server's redirect. If the return
10101002 /// value of this function is `null` then the redirect will not occur.
10111003 /// Otherwise, the returned [URLRequest] (usually `newRequest` ) will be
1012- /// executed. [onRedirect] will not be called for background sessions, which
1013- /// automatically follow redirects. See
1004+ /// executed. [onRedirect] should not throw. [onRedirect] will not be called
1005+ /// for background sessions, which automatically follow redirects. See
10141006 /// [URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:] (https://developer.apple.com/documentation/foundation/nsurlsessiontaskdelegate/1411626-urlsession)
10151007 ///
10161008 /// If [onResponse] is set then it will be called whenever a valid response
10171009 /// is received. The returned [NSURLSessionResponseDisposition] will decide
1018- /// how the content of the response is processed. See
1019- /// [URLSession:dataTask:didReceiveResponse:completionHandler:] (https://developer.apple.com/documentation/foundation/nsurlsessiondatadelegate/1410027-urlsession)
1010+ /// how the content of the response is processed. [onResponse] should not
1011+ /// throw. See
1012+ /// [URLSession:dataTask:didReceiveResponse:completionHandler:] (https://developer.apple.com/documentation/foundation/nsurlsessiondatadelegate/1410027-urlsession).
10201013 ///
10211014 /// If [onData] is set then it will be called whenever response data is
10221015 /// received. If the amount of received data is large, then it may be
0 commit comments