Guzzle: How to disable throwing exceptions on an HTTP protocol errors for asynchronous requests?

Created on 11 Jan 2016  路  1Comment  路  Source: guzzle/guzzle

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());
  }

Most helpful comment

Setting http_errors to false should disable HTTP level errors for any context. What is the exception you are getting, with stack trace?

>All comments

Setting http_errors to false should disable HTTP level errors for any context. What is the exception you are getting, with stack trace?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stof picture stof  路  5Comments

skovmand picture skovmand  路  5Comments

pedropinheiro75 picture pedropinheiro75  路  4Comments

Anan5a picture Anan5a  路  4Comments

BentCoder picture BentCoder  路  3Comments