You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 6, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 6, 2026. It is now read-only.
Wrap JsonException for better differentiation #443
In our logs we see several times JsonExceptions (Syntax error) while sending data via the REST Api. In some cases we messed up the request data and in some cases the response from the REST API is containing invalid data.
For us this is causing difficulties for us as one public method (e.g. Fulfillment::save()) is able to throw in 2 different places JsonException. For us it is impossible to act here with code.
For example: We would like to build an automated retry feature if the response body had an invalid response. If the request body conatains the syntax error we do not need to retry and would like to to notify our developers instead to fix the issue.
So here our suggestion to quickly enable everyone to determine if it was a response triggered JsonException while keeping it backward compatible:
Build a new class named ResponseJsonException extending the original JsonException. Add an additional field for the plain text response body.
In the catch block: simply throw the new ResponseJsonException with same message as the caught JsonException, add the plain boday and add the caught JsonException as previous
This will make sure all existing projects stay working and everyone is able to determine if it was an Json error in the response. You can do this as well with the Request body if you like.
If you need more details, please don't hesitate to ask.
Thanks for contributing! This package is deprecated and we're archiving this repo, so we're closing all open issues and PRs. Please use shopify-app-php instead, and open new issues there. More context: Rethinking support for PHP/Python packages
Hello
In our logs we see several times JsonExceptions (Syntax error) while sending data via the REST Api. In some cases we messed up the request data and in some cases the response from the REST API is containing invalid data.
For us this is causing difficulties for us as one public method (e.g. Fulfillment::save()) is able to throw in 2 different places JsonException. For us it is impossible to act here with code.
For example: We would like to build an automated retry feature if the response body had an invalid response. If the request body conatains the syntax error we do not need to retry and would like to to notify our developers instead to fix the issue.
So here our suggestion to quickly enable everyone to determine if it was a response triggered JsonException while keeping it backward compatible:
shopify-api-php/src/Clients/HttpResponse.php
Line 48 in f4d177e
This will make sure all existing projects stay working and everyone is able to determine if it was an Json error in the response. You can do this as well with the Request body if you like.
If you need more details, please don't hesitate to ask.