I am building a class wrapper around the themoviedb.org api. I'm using guzzle 7 for the requests, but it seems that it is not throwing any exception.
namespace App\Classes;
use App\Models\Movie;
use App\Models\Series;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\RequestInterface;
class TMDBScraper{
private string $apiKey;
private string $language;
private Client $client;
private const API_URL = "http://api.themoviedb.org/3/";
private const IMAGE_URL = "http://image.tmdb.org/t/p/";
private const POSTER_PATH_SIZE = "w500";
private const BACKDROP_PATH_SIZE = "original";
public function __construct(string $apiKey = "default_api_key") {
    $this->apiKey = $apiKey;
    $this->language = app()->getLocale();
    $handlerStack = new HandlerStack(new CurlHandler());
    $handlerStack->unshift(Middleware::mapRequest(function (RequestInterface $request) {
        return $request->withUri(Uri::withQueryValues($request->getUri(), [
            'api_key' => $this->apiKey,
            'language' => $this->language
        ]));
    }));
    $this->client = new Client([
        'base_uri' => self::API_URL,
        'handler' => $handlerStack
    ]);
}
public function search($screenplayType, $query): ?array {
    try {
        $response = json_decode($this->client->get('search/' . $screenplayType, [
            'query' => compact('query')
        ])->getBody());
        return $this->toModel($response, $screenplayType);
    } catch (GuzzleException $e) {
        echo $e->getMessage();
        return null;
    }
}
... more code }
I tried to use a wrong api key, but the client exception is not thrown. I also tried to set http_errors to true, that should be set by default, but it didn't work too.