Skip to content

Commit

Permalink
Use stream_socket_client() exception for better message
Browse files Browse the repository at this point in the history
  • Loading branch information
rudiedirkx committed Sep 28, 2023
1 parent 652fb25 commit e60e30f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,20 @@ protected function fetchCertificates(string $hostName): array
$connectTo = $hostName;
}

$client = @stream_socket_client(
"ssl://{$connectTo}:{$this->port}",
$errorNumber,
$errorDescription,
$this->timeout,
STREAM_CLIENT_CONNECT,
$streamContext
);
try {
$client = stream_socket_client(
"ssl://{$connectTo}:{$this->port}",
$errorNumber,
$errorDescription,
$this->timeout,
STREAM_CLIENT_CONNECT,
$streamContext
);
}
catch (\ErrorException $ex) {
$client = null;
$errorDescription = trim(str_replace('stream_socket_client():', '', $ex->getMessage()));
}

if (! empty($errorDescription)) {
throw $this->buildFailureException($connectTo, $errorDescription);
Expand Down

0 comments on commit e60e30f

Please sign in to comment.