phpokeapi icon indicating copy to clipboard operation
phpokeapi copied to clipboard

Client breaks when a NetworkException is thrown

Open davidecarbone opened this issue 5 years ago • 0 comments

Whenever a call to PokeAPI returns an http code different from 200, Client attempts to throw a NetworkException, which cannot be built due to conflicts with the inherited \Exception constructor.

To reproduce:

$api = new \PokeAPI\Client();
$api->pokemon('badName')->getId();

Possible hotfix Replace: throw new NetworkException($url, $data);

with: throw NetworkException::create($url, $data);

in Client.php:699

davidecarbone avatar Dec 06 '19 17:12 davidecarbone