I am sending concurrent asynchronous requests and I would like to retrieve fulfilled promises with the error status code when a request fails.
I am setting the 'http_errors' option to false but I am still getting an exception. Is there a way to disable throwing exceptions?
$client = new \GuzzleHttp\Client();
$promises = [];
foreach ($urls as $key => $url) {
$promises[$key] = $client->requestAsync('HEAD', $url, ['http_errors' => false]);
}
try {
$results = \GuzzleHttp\Promise\unwrap($promises);
$response = [];
foreach ($results as $key => $result) {
$response[$key] = $results[$key]->getStatusCode();
}
return $response;
} catch (\GuzzleHttp\Exception\RequestException $e) {
throw new BadRequestHttpException($e->getMessage());
}
Setting http_errors to false should disable HTTP level errors for any context. What is the exception you are getting, with stack trace?
Most helpful comment
Setting
http_errorsto false should disable HTTP level errors for any context. What is the exception you are getting, with stack trace?