openfoodfacts / openfoodfacts-php

PHP wrapper for Open Food Facts
https://packagist.org/packages/openfoodfacts/openfoodfacts-php
MIT License
58 stars 34 forks source link

How to handle "Your request has been redirect" error? #41

Closed khalyomede closed 4 months ago

khalyomede commented 2 years ago

Story

My error reporter reported this error, and when I read the source code I did not understood what is the root cause of this error. No comment explains this case, and at the end I do not how to handle this error: should I consider it a failure after scanning a bar code? Should I try again? If yes, how many time before I should abandon retrying?

Part of

epalmans commented 2 years ago

could you kindly provide code/tests in order to replicate this?

Dwarfex commented 2 years ago

Could you provide the Line of Code where this issue arises?

I could imagine this was a Guzzle Http Exception notifing, that the requestet resource was somewhere else with a Redirect Header (which we could ignore for now if we still get the correct result)

khalyomede commented 2 years ago

My report tool mention this line that cause the unhandled exception

https://github.com/openfoodfacts/openfoodfacts-php/blob/0.2.4/src/Api.php#L416

I noticed this is not part of the develop branch anymore, I guess it should be cleaned in future versions right?

To answer you @epalmans I am not able to always reproduce it, my code (called through openfoodfact-laravel) just speaks with this package when I search for a product from a bar code, nothing fancy).

Benoit382 commented 4 months ago

The trigger_error has been removed, no more error is triggered (only warning log). I close the issues