From ff956ae188de7f0230e9bfa2cf76895051882117 Mon Sep 17 00:00:00 2001 From: Heinz Wiesinger Date: Tue, 15 Mar 2022 15:54:09 +0100 Subject: [PATCH] Revert "Requests: Combine handling of Exception and InvalidArgument in one catch" Multi-catch is PHP 7.1+, and we still need to support 5.6 This reverts commit 11faa0f93fd0da3b81e2818adf84e6062dfe9923. --- src/Requests.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Requests.php b/src/Requests.php index e1bf27be3..65c6a6610 100644 --- a/src/Requests.php +++ b/src/Requests.php @@ -473,11 +473,19 @@ public static function request($url, $headers = [], $data = [], $type = self::GE $options['hooks']->dispatch('requests.before_parse', [&$response, $url, $headers, $data, $type, $options]); $parsed_response = self::parse_response($response, $url, $headers, $data, $options); - } catch (Exception|InvalidArgument $e) { + } catch (Exception $e) { + if ($e->failed_hook_handled === FALSE) { + $options['hooks']->dispatch('requests.failed', [&$e, $url, $headers, $data, $type, $options]); + $e->failed_hook_handled = TRUE; + } + + throw $e; + } catch (InvalidArgument $e) { if ($e->failed_hook_handled === FALSE) { $options['hooks']->dispatch('requests.failed', [&$e, $url, $headers, $data, $type, $options]); $e->failed_hook_handled = TRUE; } + throw $e; }