Skip to content

Commit

Permalink
fix: add catch for error with 200er status code #1
Browse files Browse the repository at this point in the history
  • Loading branch information
stroebjo committed Dec 1, 2016
1 parent 6638122 commit 7774ff1
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions app.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,32 @@


$data = $json;
$xml = "<?xml version=\"1.0\"?>\n<items>\n";
$xml = "<?xml version=\"1.0\"?>\n<items>\n";

//
// Github API returened some sort of error.
//
if (200 !== (int) $http_status) {
$xml .= "<item arg=\"" . $data['documentation_url'] . "\">\n";
$xml .= "<title>GitHub Response Error (" . $http_status . ")</title>\n";
$xml .= "<subtitle>" . $data['message'] . "</subtitle>\n";
$xml .= "<icon>icon.png</icon>\n";
$xml .= "</item>\n";

$xml .= "<item arg=\"http://developer.github.com/v3/#rate-limiting\">\n";
$xml .="</items>";

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 .= "<item arg=\"" . $data['documentation_url'] . "\">\n";
$xml .= "<title>GitHub Response Error (" . $http_status . ")</title>\n";
$xml .= "<subtitle>" . $resp . "</subtitle>\n";
$xml .= "<subtitle>" . $data['message'] . "</subtitle>\n";
$xml .= "<icon>icon.png</icon>\n";
$xml .= "</item>\n";

Expand Down

0 comments on commit 7774ff1

Please sign in to comment.