Created
October 25, 2013 09:12
-
-
Save craigtaub/7151883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function _getIblError($response) { | |
try { | |
$body = $response->getBody(); | |
if (!$body) { | |
return "No body content"; | |
} | |
$json = json_decode($body); | |
if (!$json) { | |
return "Unable to parse body content"; | |
} | |
if (isset($json->error, $json->error->details)) { | |
if (isset($json->error->id)) { | |
return sprintf("[%s] %s", $json->error->id, $json->error->details); | |
} | |
return $json->error->details; | |
} | |
return "Unable to retrieve error details."; | |
} catch (Exception $e) { | |
$this->_throwError($e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment