@@ -426,11 +426,20 @@ public static function request($url, $headers = array(), $data = array(), $type
426426 $ capabilities = array ('ssl ' => $ need_ssl );
427427 $ transport = self ::get_transport ($ capabilities );
428428 }
429- $ response = $ transport ->request ($ url , $ headers , $ data , $ options );
430429
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+ }
432441
433- return self :: parse_response ( $ response , $ url , $ headers , $ data , $ options ) ;
442+ return $ parsed_response ;
434443 }
435444
436445 /**
0 commit comments