From bd93f7ad692cc25578c1249f404e0efaf38a1f51 Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Tue, 26 Dec 2023 20:20:33 +0200 Subject: [PATCH] Add debugging messages --- api/index.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/index.php b/api/index.php index 7f29b0a..4a545ee 100644 --- a/api/index.php +++ b/api/index.php @@ -88,6 +88,12 @@ $images = json_decode(curlGetContents($GITHUB_API_URL, $REPO), true); // if the random query string parameter is set, pick a random image if (isset($_GET['random'])) { // get the image url + if (empty($images)) { + exit("Error: images could not be parsed from GitHub API: " . print_r($images, true)); + } + if (!is_array($images[array_rand($images)])) { + exit("Error: image was not an array: " . print_r($images[array_rand($images)], true)); + } $random_image_path = $images[array_rand($images)]["download_url"]; displayImage($random_image_path, $REPO, $redirect); } @@ -307,4 +313,4 @@ if (isset($_GET['random'])) { - + \ No newline at end of file