Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommandException doesn't contain response data #44

Closed
masterjus opened this issue Aug 11, 2014 · 5 comments
Closed

CommandException doesn't contain response data #44

masterjus opened this issue Aug 11, 2014 · 5 comments

Comments

@masterjus
Copy link

What we do:

try {
            $item = $client->storeItem([
                    'any' => 'data'
            ]);
        } catch (CommandException $ex) {
            return $this->respondCommandException(
                  $exception->getTransaction()->getResponse()->json(),
                  $exception->getTransaction()->getResponse()->getStatusCode()
            );
        }

We're receiving errors from API and pass them to view. But $exception->getTransaction()->getResponse() is null.

@mtdowling
Copy link
Member

The response wont always be set, for example, when a networking error occurs. This is something you need to account for when working with these exceptions.

@masterjus
Copy link
Author

How can we get status code?
Without status code we don't know what happened

@mtdowling
Copy link
Member

There is no status code if a networking error occurs because no response was received.

You can check the error message of the exception for more specifics on the error. More generally speaking, if no response is set then it tells you a networking error occurred.

On Aug 11, 2014, at 12:54 AM, Eugene Kirdzei notifications@github.com wrote:

How can we get status code?
Without status code we don't know what happend


Reply to this email directly or view it on GitHub.

@masterjus
Copy link
Author

I checked what error was sent from API. It just validation error message with status 400.
Should $exception->getTransaction()->getResponse()->json() work correct?

@mtdowling
Copy link
Member

This seems to be fixed now. Also note that you can use $exception->getResponse() now as well.

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

No branches or pull requests

2 participants