Skip to content

Commit

Permalink
Merge pull request #16 from steeve-christen/bug/error-handler-notice-…
Browse files Browse the repository at this point in the history
…converting-array-to-string

Handled notice about $error that cannot be converted to string.
  • Loading branch information
curzio-della-santa committed Nov 20, 2015
2 parents bb786ca + 6af7e54 commit 2872ae6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Denner/Client/Subscriber/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ protected function getErrorMessage(Response $response)
$error = $response->getReasonPhrase(); // e.g. "Bad Request"

try {
// We might be able to fetch an error message from the response
$responseData = $response->json();
if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) {
// We might be able to fetch an error message from the response
$responseData = $response->json();

if (isset($responseData['title'])) {
$error = $responseData['title'];
}
if (isset($responseData['title'])) {
$error = $responseData['title'];
}

if (isset($responseData['detail'])) {
$error .= ': ' . $responseData['detail'];
if (isset($responseData['detail'])) {
$error .= ': ' . $responseData['detail'];
}
}
} catch (ParseException $e) {
// Do nothing
Expand Down

0 comments on commit 2872ae6

Please sign in to comment.