class ExceptionCollection

Collection of exceptions

Hierarchy

  • class \Guzzle\Common\Exception\ExceptionCollection extends \Guzzle\Common\Exception\Exception implements \Guzzle\Common\Exception\IteratorAggregate, \Guzzle\Common\Exception\Countable, GuzzleException

Expanded class hierarchy of ExceptionCollection

3 files declare their use of ExceptionCollection
Client.php in drupal/core/vendor/guzzle/http/Guzzle/Http/Client.php
CurlMultiInterface.php in drupal/core/vendor/guzzle/http/Guzzle/Http/Curl/CurlMultiInterface.php
MultiTransferException.php in drupal/core/vendor/guzzle/http/Guzzle/Http/Exception/MultiTransferException.php

File

drupal/core/vendor/guzzle/common/Guzzle/Common/Exception/ExceptionCollection.php, line 8

Namespace

Guzzle\Common\Exception
View source
class ExceptionCollection extends \Exception implements GuzzleException, \IteratorAggregate, \Countable {

  /**
   * @var array Array of Exceptions
   */
  protected $exceptions = array();

  /**
   * Set all of the exceptions
   *
   * @param array $exceptions Array of exceptions
   *
   * @return self
   */
  public function setExceptions(array $exceptions) {
    $this->exceptions = $exceptions;
    return $this;
  }

  /**
   * Add exceptions to the collection
   *
   * @param ExceptionCollection|\Exception $e Exception to add
   *
   * @return ExceptionCollection;
   */
  public function add($e) {
    if ($e instanceof self) {
      foreach ($e as $exception) {
        $this->exceptions[] = $exception;
      }
    }
    elseif ($e instanceof \Exception) {
      $this->exceptions[] = $e;
    }
    $this->message = implode("\n", array_map(function ($e) {
      return $e
        ->getMessage();
    }, $this->exceptions));
    return $this;
  }

  /**
   * Get the total number of request exceptions
   *
   * @return int
   */
  public function count() {
    return count($this->exceptions);
  }

  /**
   * Allows array-like iteration over the request exceptions
   *
   * @return \ArrayIterator
   */
  public function getIterator() {
    return new \ArrayIterator($this->exceptions);
  }

  /**
   * Get the first exception in the collection
   *
   * @return \Exception
   */
  public function getFirst() {
    return $this->exceptions ? $this->exceptions[0] : null;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ExceptionCollection::$exceptions protected property
ExceptionCollection::add public function Add exceptions to the collection
ExceptionCollection::count public function Get the total number of request exceptions
ExceptionCollection::getFirst public function Get the first exception in the collection
ExceptionCollection::getIterator public function Allows array-like iteration over the request exceptions
ExceptionCollection::setExceptions public function Set all of the exceptions