我已经设置了ZendSkeletonApplication,ZF 2.0.3
但我无法在我的控制器中捕获异常。例如,如果我将以下代码放入module/Application/src/Application/Controller/IndexController.php
:
public function indexAction() {
echo "BEFORE\n";
try {
throw new \Exception("My exception");
} catch (Exception $e) {
echo "Caught exception $e\n";
exit;
}
并访问我得到的页面:
BEFORE
An error occurred
An error occurred during execution; please try again later.
Additional information:
Exception
File:
module/Application/src/Application/Controller/IndexController.php:25
Message:
My exception
启动ViewModel
并显示异常,有效地阻止我捕捉它。
如何在ZF2
控制器中捕获异常?