Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Handle error response with empty body #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gapple
Copy link

@gapple gapple commented Jan 13, 2017

The current code:

  if (is_array($content)) {
    $error = $content[0];
    if (400 == $response->getStatusCode()) {

doesn't handle if the response is an empty array, and ends up causing an "Undefined offset: 0" exception that masks the error from the API. I encountered this in a couple circumstances, typically with a 500 error that wasn't handled meaningfully either.

This probably needs some improvement, but it at least allowed me to handle errors a little better in my application.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant