Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Added support for PHP7 \Throwable based exceptions #138

Merged
merged 3 commits into from
May 31, 2016

Conversation

maurice2k
Copy link
Contributor

No description provided.


try {
$return = $controller->dispatch($request, $response);
} catch (\Throwable $ex) {

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?

Copy link
Contributor Author

@maurice2k maurice2k May 3, 2016

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).

Copy link
Member

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?

Copy link
Contributor Author

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.

@weierophinney weierophinney added this to the 2.7.8 milestone May 31, 2016
@weierophinney weierophinney self-assigned this May 31, 2016
@@ -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
Copy link
Member

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.

Copy link
Member

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.

@weierophinney weierophinney merged commit 0cd4135 into zendframework:master May 31, 2016
weierophinney added a commit that referenced this pull request May 31, 2016
Added support for PHP7 \Throwable based exceptions
weierophinney added a commit that referenced this pull request May 31, 2016
weierophinney added a commit that referenced this pull request May 31, 2016
weierophinney added a commit that referenced this pull request May 31, 2016
weierophinney added a commit to weierophinney/zend-mvc-console that referenced this pull request May 31, 2016
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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants