@@ -369,6 +369,7 @@ function AFFailure(
369369 let response = error . userInfo . valueForKey (
370370 AFNetworkingOperationFailingURLResponseErrorKey
371371 ) as NSHTTPURLResponse ;
372+ console . log ( 'AFFailu re' , error , Utils . isNullOrUndefined ( response ) , response ) ;
372373 if ( ! Utils . isNullOrUndefined ( response ) ) {
373374 sendi . statusCode = response . statusCode ;
374375 getHeaders = function ( ) {
@@ -392,6 +393,9 @@ function AFFailure(
392393 let parsedData = getData ( data ) ;
393394 const failingURL = error . userInfo . objectForKey ( "NSErrorFailingURLKey" ) ;
394395 if ( useLegacy ) {
396+ if ( ! sendi . statusCode ) {
397+ return reject ( error . localizedDescription ) ;
398+ }
395399 let failure : any = {
396400 description : error . description ,
397401 reason : error . localizedDescription ,
@@ -404,7 +408,6 @@ function AFFailure(
404408 }
405409 sendi . failure = failure ;
406410 sendi . content = new HttpsResponse ( data , url ) ;
407-
408411 resolve ( sendi ) ;
409412 } else {
410413 let content : any = {
@@ -529,7 +532,7 @@ export function createRequest(
529532 run ( resolve , reject ) {
530533 const success = function ( task : NSURLSessionDataTask , data ?: any ) {
531534 // TODO: refactor this code with failure one.
532- let content = useLegacy
535+ let content = useLegacy
533536 ? new HttpsResponse ( data , opts . url )
534537 : getData ( data ) ;
535538 let getHeaders = ( ) => ( { } ) ;
0 commit comments