Skip to content

Conversation

@roland-d
Copy link

I was doing asset uploads to Bol.com and all I received was the message Bad Request. Not very informative :)

So I did some digging and at some point received the first part of the message but the rest was truncated due to the large message it is.

After some more digging I found out that we can enlarge the size of the response message, that is my first change in the constructor.

As I was still getting the Bad Request message I dug further and found that Guzzle throws a ClientException which is not caught and as a result I just get the Bad Request. So this is the second change in this file where I catch the ClientException and then throw it as a RequestException that contains the full message from the ClientException.

The result is that I receive the full message in my code and can deal with it accordingly. The source of my error was uploading assets without labels. That is what the real error message is telling me :)

I was doing asset uploads to Bol.com and all I received was the message `Bad Request`. Not very informative :)

So I did some digging and at some point received the first part of the message but the rest was truncated due to the large message it is.

After some more digging I found out that we can enlarge the size of the response message, that is my first change in the constructor.

As I was still getting the `Bad Request` message I dug further and found that Guzzle throws a `ClientException` which is not caught and as a result I just get the `Bad Request`. So this is the second change in this file where I catch the  `ClientException` and then throw it as a `RequestException` that contains the full message from the `ClientException`.

The result is that I receive the full message in my code and can deal with it accordingly. The source of my error was uploading assets without labels. That is what the real error message is telling me :)
@casperbakker
Copy link
Member

Thank you for your contribution. Can you maybe show a code example in the PR here? What kind of error will be caught with this, what will the new message/exception be in that case? Then I can merge it with full understanding.

@roland-d
Copy link
Author

Hi @casperbakker

I will try but it's been 3 months 😅

The original code comes from this page: https://akrabat.com/increase-truncated-body-in-a-guzzle-exception/

Can you maybe show a code example in the PR here?

$this->client = new Client();
$this->client->authenticateByClientCredentials('invalidid', 'invalidsecret');

This will throw the ClientException.

What kind of error will be caught with this

Any client exception. I don't have the exact code readily available anymore.

what will the new message/exception be in that case?

Guzzle throws a ClientException and that is not caught in the rawRequest() function. So it bubbles up. By adding a catch statement for the ClientException we can handle it properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants