ZendFrameWork2
実現したいこと
すべてのレベル(Noticeであっても)で、エラー発生時にerror.phtmlに
stacktraceを出力したい
出力先
views/script/error/error.ptml
application/controllers/errorControllers.php
php
1 public function errorAction() 2 { 3 $errors = $this->_getParam('error_handler'); 4 switch ($errors->type) { 5 case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: 6 case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: 7 case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: 8 $this->getResponse()->setHttpResponseCode(404); 9 $priority = Zend_Log::NOTICE; 10 $this->view->message = 'Page not found'; 11 break; 12 default: 13 $this->getResponse()->setHttpResponseCode(500); 14 $priority = Zend_Log::CRIT; 15 $this->view->message = 'Application error'; 16 break; 17 } 18 }
■試してみたこと
views/stript/error/error.ptml
に、
html
1 <h3>Message:</h3> 2 <pre><?php echo $this->message ?> 3 </pre> 4 <h3>Stack trace:</h3> 5 <pre><?php echo $this->exception->getTraceAsString() ?> 6 </pre>
を追加
その結果、なにも表示されない
あなたの回答
tips
プレビュー