File tree Expand file tree Collapse file tree 4 files changed +13
-1
lines changed
Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 2828require_once __DIR__ . "/lib/exceptions/NoDieException.php " ;
2929require_once __DIR__ . "/lib/exceptions/SSOException.php " ;
3030require_once __DIR__ . "/lib/exceptions/ArrayKeyException.php " ;
31+ require_once __DIR__ . "/lib/exceptions/CurlException.php " ;
3132require_once __DIR__ . "/lib/exceptions/EntryNotFoundException.php " ;
3233require_once __DIR__ . "/lib/exceptions/EnsureException.php " ;
3334require_once __DIR__ . "/lib/exceptions/EncodingUnknownException.php " ;
Original file line number Diff line number Diff line change 11<?php
22
33namespace UnityWebPortal \lib ;
4+ use UnityWebPortal \lib \exceptions \CurlException ;
45
56class UnityGithub
67{
@@ -13,7 +14,11 @@ public function getSshPublicKeys(string $username): array
1314 curl_setopt ($ curl , CURLOPT_URL , $ url );
1415 curl_setopt ($ curl , CURLOPT_RETURNTRANSFER , 1 );
1516 curl_setopt ($ curl , CURLOPT_HTTPHEADER , $ headers );
16- $ keys = json_decode (curl_exec ($ curl ), false );
17+ $ curl_output = curl_exec ($ curl );
18+ if ($ curl_output === false ) {
19+ throw new CurlException (curl_error ($ curl ));
20+ }
21+ $ keys = json_decode ($ curl_output , false );
1722 curl_close ($ curl );
1823
1924 // normally returns array of objects each with a ->key attribute
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace UnityWebPortal \lib \exceptions ;
4+
5+ class CurlException extends \Exception {}
Original file line number Diff line number Diff line change 1919require_once __DIR__ . "/../resources/lib/exceptions/NoDieException.php " ;
2020require_once __DIR__ . "/../resources/lib/exceptions/SSOException.php " ;
2121require_once __DIR__ . "/../resources/lib/exceptions/ArrayKeyException.php " ;
22+ require_once __DIR__ . "/../resources/lib/exceptions/CurlException.php " ;
2223require_once __DIR__ . "/../resources/lib/exceptions/EntryNotFoundException.php " ;
2324require_once __DIR__ . "/../resources/lib/exceptions/EnsureException.php " ;
2425require_once __DIR__ . "/../resources/lib/exceptions/EncodingUnknownException.php " ;
You can’t perform that action at this time.
0 commit comments