Skip to content
This repository has been archived by the owner on Jul 15, 2021. It is now read-only.

Commit

Permalink
Fixed issue with error, for stopwatch subscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
csarrazi committed Jan 13, 2015
1 parent 8b80728 commit 7dd773d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion dist/GuzzleHttp/Subscriber/StopwatchSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use GuzzleHttp\Event\CompleteEvent;
use GuzzleHttp\Event\BeforeEvent;
use GuzzleHttp\Event\ErrorEvent;
use GuzzleHttp\Event\RequestEvents;
use GuzzleHttp\Event\SubscriberInterface;
use Symfony\Component\Stopwatch\Stopwatch;
Expand All @@ -36,7 +37,7 @@ public function getEvents()
return [
'before' => ['onBefore', RequestEvents::EARLY],
'complete' => ['onFinish', RequestEvents::LATE],
'error' => ['onFinish', RequestEvents::EARLY],
'error' => ['onError', RequestEvents::EARLY],
];
}

Expand All @@ -55,4 +56,15 @@ public function onFinish(CompleteEvent $event)

$this->stopwatch->stop($url);
}

public function onError(ErrorEvent $event)
{
$url = $event->getRequest()->getUrl();

if (!$this->stopwatch->isStarted($url)) {
return;
}

$this->stopwatch->stop($url);
}
}

0 comments on commit 7dd773d

Please sign in to comment.