From a5c6ec5883a0f5d7d18089c7b4198831a9830add Mon Sep 17 00:00:00 2001 From: webimpress Date: Fri, 3 Jun 2016 00:03:37 +0100 Subject: [PATCH] consistent names for exception --- src/MiddlewareListener.php | 10 +++++----- src/View/Http/DefaultRenderingStrategy.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/MiddlewareListener.php b/src/MiddlewareListener.php index 4c19672ea..5ea4efe15 100644 --- a/src/MiddlewareListener.php +++ b/src/MiddlewareListener.php @@ -60,10 +60,10 @@ public function onDispatch(MvcEvent $event) $caughtException = null; try { $return = $middleware(Psr7Request::fromZend($request), Psr7Response::fromZend($response)); - } catch (\Throwable $exception) { - $caughtException = $exception; - } catch (\Exception $exception) { // @TODO clean up once PHP 7 requirement is enforced - $caughtException = $exception; + } catch (\Throwable $ex) { + $caughtException = $ex; + } catch (\Exception $ex) { // @TODO clean up once PHP 7 requirement is enforced + $caughtException = $ex; } if ($caughtException !== null) { @@ -71,7 +71,7 @@ public function onDispatch(MvcEvent $event) $event->setError($application::ERROR_EXCEPTION); $event->setController($middlewareName); $event->setControllerClass(get_class($middleware)); - $event->setParam('exception', $exception); + $event->setParam('exception', $caughtException); $events = $application->getEventManager(); $results = $events->triggerEvent($event); diff --git a/src/View/Http/DefaultRenderingStrategy.php b/src/View/Http/DefaultRenderingStrategy.php index 71bb74a6a..714f2d324 100644 --- a/src/View/Http/DefaultRenderingStrategy.php +++ b/src/View/Http/DefaultRenderingStrategy.php @@ -111,14 +111,14 @@ public function render(MvcEvent $e) if ($caughtException !== null) { if ($e->getName() === MvcEvent::EVENT_RENDER_ERROR) { - throw $ex; + throw $caughtException; } $application = $e->getApplication(); $events = $application->getEventManager(); $e->setError(Application::ERROR_EXCEPTION); - $e->setParam('exception', $ex); + $e->setParam('exception', $caughtException); $e->setName(MvcEvent::EVENT_RENDER_ERROR); $events->triggerEvent($e); }