ZF2-414: Throwing exception in template (and/or layout) doesnt fails gracefully

Description

template.phtml

<? throw \Exception('error');

shows: Fatal error: Uncaught exception 'Exception' with message 'error' in /path/to/template.phtml on line 2

I would expect to catch those exceptions and forward (eg by forward plugin) to 404 page.

Comments

Why would you expect an exception in the view to lead to a 404 page? This makes no sense to me -- the route clearly was handled. If anything, I would expect a 500 page to occur. I'll mark this as a feature request for such functionality.

Not a critical issue, so downgrading to minor priority. Also modified issue type to "Improvement".

Correct, 500 page for sure.

But I see it as serious issue, because everyone who rely on lazyloading heavily, will run into exceptions just because everything is loaded once the Model classes are accessed in view layer. And also because there is no easy workaround how to emulate this by events. Or is there?

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf2/issues/2506