Skip to content

Commit c872ed5

Browse files
committed
Adding support for PHP8 exception for the CurlHttpClient
1 parent 2d03d76 commit c872ed5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/CurlHttpClient.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace Pdp;
1717

18+
use Throwable;
1819
use function curl_close;
1920
use function curl_errno;
2021
use function curl_error;
@@ -52,8 +53,13 @@ public function __construct(array $options = [])
5253
CURLOPT_HTTPGET => true,
5354
];
5455

55-
$curl = curl_init();
56-
$res = @curl_setopt_array($curl, $this->options);
56+
try {
57+
$curl = curl_init();
58+
$res = @curl_setopt_array($curl, $this->options);
59+
} catch (Throwable $exception) {
60+
throw new Exception('Please verify your curl additionnal options', $exception->getCode(), $exception);
61+
}
62+
5763
curl_close($curl);
5864
if (!$res) {
5965
throw new Exception('Please verify your curl additionnal options');

0 commit comments

Comments
 (0)