@@ -426,11 +426,20 @@ public static function request($url, $headers = array(), $data = array(), $type
426
426
$ capabilities = array ('ssl ' => $ need_ssl );
427
427
$ transport = self ::get_transport ($ capabilities );
428
428
}
429
- $ response = $ transport ->request ($ url , $ headers , $ data , $ options );
430
429
431
- $ options ['hooks ' ]->dispatch ('requests.before_parse ' , array (&$ response , $ url , $ headers , $ data , $ type , $ options ));
430
+ try {
431
+ $ response = $ transport ->request ($ url , $ headers , $ data , $ options );
432
+
433
+ $ options ['hooks ' ]->dispatch ('requests.before_parse ' , array (&$ response , $ url , $ headers , $ data , $ type , $ options ));
434
+
435
+ $ parsed_response = self ::parse_response ($ response , $ url , $ headers , $ data , $ options );
436
+ }
437
+ catch (Requests_Exception $ e ) {
438
+ $ options ['hooks ' ]->dispatch ('requests.failed ' , array ($ e , $ url , $ headers , $ data , $ type , $ options ));
439
+ throw $ e ;
440
+ }
432
441
433
- return self :: parse_response ( $ response , $ url , $ headers , $ data , $ options ) ;
442
+ return $ parsed_response ;
434
443
}
435
444
436
445
/**
0 commit comments