Skip to content

Commit

Permalink
Requests: Combine handling of Exception and InvalidArgument in one catch
Browse files Browse the repository at this point in the history
  • Loading branch information
pprkut committed Mar 14, 2022
1 parent e35fa45 commit 11faa0f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/Requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,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) {
$options['hooks']->dispatch('requests.failed', [&$e, $url, $headers, $data, $type, $options]);
throw $e;
}

Expand Down

0 comments on commit 11faa0f

Please sign in to comment.