Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requests: Add "requests.failed" hook #582

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
Requests: Combine handling of Exception and InvalidArgument in one catch
  • Loading branch information
pprkut committed Feb 28, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit 7ace642fde39fc4b7de4a2a6916f0468d112091b
7 changes: 2 additions & 5 deletions src/Requests.php
Original file line number Diff line number Diff line change
@@ -471,11 +471,8 @@ 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 $e) {
$options['hooks']->dispatch('requests.failed', [$e, $url, $headers, $data, $type, $options]);
throw $e;
} catch (InvalidArgument $e) {
$options['hooks']->dispatch('requests.failed', [$e, $url, $headers, $data, $type, $options]);
} catch (Exception|InvalidArgument $e) {
pprkut marked this conversation as resolved.
Show resolved Hide resolved
$options['hooks']->dispatch('requests.failed', [&$e, $url, $headers, $data, $type, $options]);
throw $e;
}