-
Notifications
You must be signed in to change notification settings - Fork 89
Added support for PHP7 \Throwable based exceptions #138
Conversation
|
||
try { | ||
$return = $controller->dispatch($request, $response); | ||
} catch (\Throwable $ex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't Exception
be caught prior to Throwable
? As Exception extends Throwable and would therefore never be caught?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes no difference as the code is the same for \Exception
and \Throwable
. In PHP 7+ the exceptions or error exceptions are caught by \Throwable
whereas in PHP 5 the exceptions are caught by \Exception
.
\Exception
should be removed at some point in the future (wenn PHP5 support is dropped).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a // @TODO clean up once PHP 7 requirement is enforced
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, just added the todos.
@@ -184,7 +184,7 @@ public function prepareExceptionViewModel(MvcEvent $e) | |||
if (is_callable($this->message)) { | |||
$callback = $this->message; | |||
$message = (string) $callback($exception, $this->displayExceptions); | |||
} elseif ($this->displayExceptions && $exception instanceof \Exception) { | |||
} elseif ($this->displayExceptions && ($exception instanceof \Exception || $exception instanceof \Throwable)) { // @TODO clean up once PHP 7 requirement is enforced |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you open a related issue on zend-mvc-console, please? This functionality is moved into there for the v3 series.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind; I'm working on it now.
Added support for PHP7 \Throwable based exceptions
Based on zendframework/zend-mvc#138, this patch adds support for handling any Throwable, not just Exceptions, when reporting exceptions and route not found information; the patch includes tests of both changes in behavior.
No description provided.