Skip to content

Instantly share code, notes, and snippets.

@craigtaub
Created October 25, 2013 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigtaub/7151883 to your computer and use it in GitHub Desktop.
Save craigtaub/7151883 to your computer and use it in GitHub Desktop.
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