public function onError(ErrorEvent $event)
 {
     if ($event->getResponse()) {
         $this->log->error('guzzle_error: ' . $event->getException()->getMessage());
     } else {
         $ex = $event->getException();
         $this->log->error($ex->getMessage() . ' -- ' . $ex->getTraceAsString(), [$ex->getCode(), $ex->getLine(), $ex->getFile()]);
     }
     $event->stopPropagation();
 }
 public function testInterceptsWithEvent()
 {
     $client = new Client();
     $request = new Request('GET', '/');
     $response = new Response(404);
     $transaction = new Transaction($client, $request);
     $except = new RequestException('foo', $request, $response);
     $event = new ErrorEvent($transaction, $except);
     $event->throwImmediately(true);
     $this->assertTrue($except->getThrowImmediately());
     $event->throwImmediately(false);
     $this->assertFalse($except->getThrowImmediately());
     $this->assertSame($except, $event->getException());
     $this->assertSame($response, $event->getResponse());
     $this->assertSame($request, $event->getRequest());
     $res = null;
     $request->getEmitter()->on('complete', function ($e) use(&$res) {
         $res = $e;
     });
     $good = new Response(200);
     $event->intercept($good);
     $this->assertTrue($event->isPropagationStopped());
     $this->assertSame($res->getClient(), $event->getClient());
     $this->assertSame($good, $res->getResponse());
 }
示例#3
0
 public function testInterceptsWithEvent()
 {
     $t = new Transaction(new Client(), new Request('GET', '/'));
     $except = new RequestException('foo', $t->request);
     $t->exception = $except;
     $e = new ErrorEvent($t);
     $this->assertSame($e->getException(), $t->exception);
 }
 /**
  * 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());
     }
 }
 public function onError(ErrorEvent $event)
 {
     $this->logIt($event->getRequest(), $event->getResponse(), $event->getException());
 }
 /**
  * 
  * @param ErrorEvent $event
  */
 public function onError(ErrorEvent $event)
 {
     $ex = $event->getException();
     $this->logger->log(LogLevel::CRITICAL, $this->formatter->format($event->getRequest(), $event->getResponse(), $ex), ['request' => $event->getRequest(), 'response' => $event->getResponse(), 'exception' => $ex]);
     $this->rewindResponse($event->getResponse());
 }