From 7774ff1c63a86e2f49549c721b5b951af2cf01c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Stro=CC=88bele?= Date: Thu, 1 Dec 2016 10:04:09 +0100 Subject: [PATCH] fix: add catch for error with 200er status code #1 --- app.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app.php b/app.php index 9dc0f1a..059b0ab 100644 --- a/app.php +++ b/app.php @@ -69,16 +69,32 @@ $data = $json; -$xml = "\n\n"; +$xml = "\n\n"; // // Github API returened some sort of error. // if (200 !== (int) $http_status) { + $xml .= "\n"; + $xml .= "GitHub Response Error (" . $http_status . ")\n"; + $xml .= "" . $data['message'] . "\n"; + $xml .= "icon.png\n"; + $xml .= "\n"; - $xml .= "\n"; + $xml .=""; + + echo $xml; + return; +} + +// +// Also check for presence of `message` key, if HTTP Status +// code was not set to an error. +// +if (isset($data['message'])) { + $xml .= "\n"; $xml .= "GitHub Response Error (" . $http_status . ")\n"; - $xml .= "" . $resp . "\n"; + $xml .= "" . $data['message'] . "\n"; $xml .= "icon.png\n"; $xml .= "\n";