ErrorController.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. class ErrorController extends Zend_Controller_Action
  3. {
  4. public function errorAction()
  5. {
  6. $errors = $this->_getParam('error_handler');
  7. switch ($errors->type) {
  8. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
  9. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  10. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  11. // 404 error -- controller or action not found
  12. $this->getResponse()->setHttpResponseCode(404);
  13. $this->view->message = _('Page not found');
  14. break;
  15. default:
  16. // application error
  17. $this->getResponse()->setHttpResponseCode(500);
  18. $this->view->message = _('Application error');
  19. break;
  20. }
  21. // Log exception, if logger available
  22. /* No idea why this doesn't work or why it was implemented like this. Disabling it -- Albert
  23. if (($log = $this->getLog())) {
  24. $log->crit($this->view->message, $errors->exception);
  25. }*/
  26. //Logging that actually works: -- Albert
  27. Logging::error($this->view->message . ": " . $errors->exception);
  28. // conditionally display exceptions
  29. if ($this->getInvokeArg('displayExceptions') == true) {
  30. $this->view->exception = $errors->exception;
  31. }
  32. $this->view->request = $errors->request;
  33. }
  34. public function getLog()
  35. {
  36. $bootstrap = $this->getInvokeArg('bootstrap');
  37. if (!$bootstrap->hasPluginResource('Log')) {
  38. return false;
  39. }
  40. $log = $bootstrap->getResource('Log');
  41. return $log;
  42. }
  43. public function deniedAction()
  44. {
  45. // action body
  46. }
  47. }