Skip to content

Commit

Permalink
Handle GitHub errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Nov 7, 2023
1 parent 96006a4 commit a298796
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ function listLayers(string $version, string $region): array
$url = 'https://raw.githubusercontent.com/brefphp/bref/' . $version . '/layers.json';

$response = $client->get($url);
if ($response->getStatusCode() !== 200) {
throw new \RuntimeException('Could not fetch layers from GitHub');
}
$json = $response->getBody()->getContents();
$data = json_decode($json, true);

Expand Down Expand Up @@ -137,6 +140,9 @@ function listVersions(): array
$url = 'https://api.github.com/repos/brefphp/bref/releases';

$response = $client->get($url);
if ($response->getStatusCode() !== 200) {
throw new \RuntimeException('Could not fetch releases from GitHub');
}
$json = $response->getBody()->getContents();
$releases = json_decode($json, true);

Expand Down

0 comments on commit a298796

Please sign in to comment.