NicklasWallgren / PokemonGoAPI-PHP

Pokemon Go API PHP library
BSD 2-Clause "Simplified" License
130 stars 51 forks source link

Add missing check #98

Closed ghost closed 8 years ago

ghost commented 8 years ago

Can be related with #85, got same error today, after digging -> server returns 403

ghost commented 8 years ago

Added more details.

WisdomSky commented 8 years ago

Does this fix anything? It seems you're just adding a new condition to check for a possible problem and throw another unnecessary exception

The code already throws exception because it encountered a problem, so there's no need for another exception to make things more bloated, what it need is a fix to make sure that this exception will not complain again.

ghost commented 8 years ago

Its needed there since without it on my 2 accounts today i got error:

Fatal error: Uncaught exception 'Exception' with message 'Incorrect wire format for field 7, expected: 2 got: 4' in the ResponseEnvelope.php file

after some checking i found that niantic servers returns 403 for me.

ghost commented 8 years ago

Just api got html page with 403 error as response and is trying to parse it.

DrDelay commented 8 years ago

Why do you consider throwing an Exception "unnecessary". It is way better than continuing with an invalid response and running into a weird ("wire format") error that has no clue about the original problem.

The only thing that could be better is throwing a more specific Exception than "Exception", so you can catch more specifically. Or just turn Guzzle exceptions back on (I don't really see a reason why they are disabled).