@@ -466,11 +466,23 @@ public static function request($url, $headers = [], $data = [], $type = self::GE
466
466
$ transport = self ::get_transport ($ capabilities );
467
467
}
468
468
469
- $ response = $ transport ->request ($ url , $ headers , $ data , $ options );
469
+ try {
470
+ $ response = $ transport ->request ($ url , $ headers , $ data , $ options );
471
+
472
+ $ options ['hooks ' ]->dispatch ('requests.before_parse ' , [&$ response , $ url , $ headers , $ data , $ type , $ options ]);
470
473
471
- $ options ['hooks ' ]->dispatch ('requests.before_parse ' , [&$ response , $ url , $ headers , $ data , $ type , $ options ]);
474
+ $ parsed_response = self ::parse_response ($ response , $ url , $ headers , $ data , $ options );
475
+ }
476
+ catch (Exception $ e ) {
477
+ $ options ['hooks ' ]->dispatch ('requests.failed ' , [$ e , $ url , $ headers , $ data , $ type , $ options ]);
478
+ throw $ e ;
479
+ }
480
+ catch (InvalidArgument $ e ) {
481
+ $ options ['hooks ' ]->dispatch ('requests.failed ' , [$ e , $ url , $ headers , $ data , $ type , $ options ]);
482
+ throw $ e ;
483
+ }
472
484
473
- return self :: parse_response ( $ response , $ url , $ headers , $ data , $ options ) ;
485
+ return $ parsed_response ;
474
486
}
475
487
476
488
/**
0 commit comments