Skip to content

Commit 87fa4b7

Browse files
authored
Error handling for getGitHubApiResponse (#161)
* Add error handle * Update stats.php * Update stats.php * Update stats.php
1 parent 10f545f commit 87fa4b7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/stats.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ function getGitHubApiResponse(string $url): string
110110
curl_setopt($ch, CURLOPT_VERBOSE, false);
111111
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
112112
$response = curl_exec($ch);
113+
114+
//Handles curl errors
115+
if($response === false) {
116+
if(str_contains(curl_error($ch), 'unable to get local issuer certificate')) {
117+
throw new InvalidArgumentException("You don't have valid SSL Certificate installed or XAMPP.");
118+
}
119+
throw new InvalidArgumentException("Something is wrong with getGitHubApiResponse().");
120+
}
121+
113122
curl_close($ch);
114123
return $response;
115124
}

0 commit comments

Comments
 (0)