algolia / algoliasearch-client-php

⚡️ A fully-featured and blazing-fast PHP API client to interact with Algolia.
https://www.algolia.com/doc/api-client/php/getting-started/
MIT License
671 stars 116 forks source link

Include input string in message about invalid json #711

Closed greg0ire closed 1 year ago

greg0ire commented 1 year ago
Q A
Bug fix? no
New feature? yes
BC breaks? no
Related Issue n/a
Need Doc update no

Describe your change

In this PR, we include the input string that is fed to json_decode, because it will help understanding issues with it.

What problem is this fixing?

This helper is used in a single place, to decode the response coming from Algolia. If the response is invalid, the contents of the input string is lost, making it impossible to troubleshoot the error.

Here is an example of what I am currently experiencing in my application:

json_decode error: Control character error, possibly incorrectly encoded

I don't think there is a way for me to troubleshoot this.

DevinCodes commented 1 year ago

@damcou do you think we can move forward with this?