Skip to content

Commit 62792a6

Browse files
committed
prevent generic status 406 and 500 responses when encountering throwable. instanceof exception condition was retained for PHP <7.
1 parent 95d8705 commit 62792a6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Listener/ApiProblemListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function onRender(MvcEvent $e)
9696
$status = $e->getResponse()->getStatusCode();
9797
$exception = $model->getVariable('exception');
9898

99-
if ($exception instanceof \Exception) {
99+
if ($exception instanceof \Exception || $exception instanceof \Throwable) {
100100
$apiProblem = new ApiProblem($status, $exception);
101101
} else {
102102
$apiProblem = new ApiProblem($status, $model->getVariable('message'));
@@ -156,7 +156,7 @@ public function onDispatchError(MvcEvent $e)
156156

157157
// Marshall an ApiProblem and view model based on the exception
158158
$exception = $e->getParam('exception');
159-
if (! $exception instanceof \Exception) {
159+
if (! ($exception instanceof \Exception || $exception instanceof \Throwable)) {
160160
// If it's not an exception, do not know what to do.
161161
return;
162162
}

src/Listener/RenderErrorListener.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ public function onRenderError(MvcEvent $e)
6565
$details = false;
6666

6767
$exception = $e->getParam('exception');
68-
if ($exception instanceof \Exception
68+
if (
69+
(
70+
$exception instanceof \Exception
71+
|| $exception instanceof \Throwable
72+
)
6973
&& ! $exception instanceof ViewExceptionInterface
7074
) {
7175
$code = $exception->getCode();

0 commit comments

Comments
 (0)