Skip to content

Commit fe79ffe

Browse files
committed
Handle PHP 7 Throwable in ApiProblemListener.
1 parent 4eab297 commit fe79ffe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Listener/ApiProblemListener.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace ZF\ApiProblem\Listener;
99

10+
use Exception;
11+
use Throwable;
1012
use Zend\EventManager\EventManagerInterface;
1113
use Zend\EventManager\AbstractListenerAggregate;
1214
use Zend\Http\Header\Accept as AcceptHeader;
@@ -96,7 +98,7 @@ public function onRender(MvcEvent $e)
9698
$status = $e->getResponse()->getStatusCode();
9799
$exception = $model->getVariable('exception');
98100

99-
if ($exception instanceof \Exception) {
101+
if ($exception instanceof Throwable || $exception instanceof Exception) {
100102
$apiProblem = new ApiProblem($status, $exception);
101103
} else {
102104
$apiProblem = new ApiProblem($status, $model->getVariable('message'));
@@ -156,7 +158,7 @@ public function onDispatchError(MvcEvent $e)
156158

157159
// Marshall an ApiProblem and view model based on the exception
158160
$exception = $e->getParam('exception');
159-
if (! $exception instanceof \Exception) {
161+
if (! ($exception instanceof Throwable || $exception instanceof Exception)) {
160162
// If it's not an exception, do not know what to do.
161163
return;
162164
}

0 commit comments

Comments
 (0)