Skip to content

Conversation

elzozo13
Copy link

Shopify has a really good policy regarding errors and error codes described here: https://help.shopify.com/en/api/getting-started/response-status-codes (Pretty sure some of the contributors read it since 429 is mentioned in code).

The problem is that the errors ar thrown without the code. That in turn forces ppl to keep using stuff like stripos($response, '[API] Invalid API key or access token') to be able to catch exceptions and treat them. This is results in unnecessary maintenance (especially if for some reason shopify decide to change a message text). Another option would be to call the CurlRequest::$lastHttpCode from outside the php-shopify code, but that would couple the lib into the project and I don't think I need to mention why that is bad :).

I added the last http response code as an error code.

Also (I didn't treat this here but it is a problem), having the $lastHttpCode as static on curl may result in resource races with wrong outcome (unless I'm missing someting here? don't think so but hope so). I plan on adding an issue with that if that's ok with you, and making another pull request to resolve that.

@tareqtms
Copy link
Contributor

tareqtms commented Feb 1, 2020

@elzozo13
Thanks, will review it soon.

@tareqtms tareqtms merged commit 652a67f into phpclassic:master Feb 16, 2020
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

Successfully merging this pull request may close these issues.

2 participants