From 43721e66d9b772df0027d0bbc42424f821a65909 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 30 Jul 2016 05:05:51 -0400 Subject: [PATCH 1/2] Added missing import --- src/Plugin/HistoryPlugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Plugin/HistoryPlugin.php b/src/Plugin/HistoryPlugin.php index 5abddbd..d30ecb2 100644 --- a/src/Plugin/HistoryPlugin.php +++ b/src/Plugin/HistoryPlugin.php @@ -2,6 +2,7 @@ namespace Http\Client\Common\Plugin; +use Exception; use Http\Client\Common\Plugin; use Http\Client\Exception; use Psr\Http\Message\RequestInterface; From a320fd37380eb33c5e216de6fdd728b2f608ad37 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 30 Jul 2016 05:58:15 -0400 Subject: [PATCH 2/2] Tweaked the implementation --- src/Plugin/HistoryPlugin.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Plugin/HistoryPlugin.php b/src/Plugin/HistoryPlugin.php index d30ecb2..b52ae5a 100644 --- a/src/Plugin/HistoryPlugin.php +++ b/src/Plugin/HistoryPlugin.php @@ -2,7 +2,6 @@ namespace Http\Client\Common\Plugin; -use Exception; use Http\Client\Common\Plugin; use Http\Client\Exception; use Psr\Http\Message\RequestInterface; @@ -41,8 +40,10 @@ public function handleRequest(RequestInterface $request, callable $next, callabl $journal->addSuccess($request, $response); return $response; - }, function (Exception $exception) use ($request, $journal) { - $journal->addFailure($request, $exception); + }, function ($exception) use ($request, $journal) { + if ($exception instanceof Exception) { + $journal->addFailure($request, $exception); + } throw $exception; });