/**
  * @param callable $handler
  *
  * @return callable
  */
 public function __invoke(callable $handler)
 {
     return function (RequestInterface $request, array $options) use($handler) {
         return $handler($request, $options)->then(function (ResponseInterface $response) {
             return $response;
         }, function (GuzzleException $exception) {
             $this->collector->addException($exception);
             throw $exception;
         });
     };
 }
Пример #2
0
 /**
  * Method to handle error events.
  *
  * @param ErrorEvent $event
  */
 public function onError(ErrorEvent $event)
 {
     // Stop measurement and add exception information.
     $this->stopMeasure($event->getRequest(), $event->getResponse(), $event->getException());
     if ($this->exceptions) {
         $this->exceptions->addException($event->getException());
     }
 }
 /**
  * Add an exception to the collector.
  *
  * @param \Exception $exception The exception.
  *
  * @return void
  */
 protected static function addException($exception)
 {
     self::$collector->addException($exception);
 }