PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/application/controllers/ErrorController.php

https://bitbucket.org/hieronim1981/tunethemusic
PHP | 58 lines | 43 code | 11 blank | 4 comment | 7 complexity | 66a63f522b6f45aad849791dce6c6d92 MD5 | raw file
  1. <?php
  2. class ErrorController extends Zend_Controller_Action
  3. {
  4. public function errorAction()
  5. {
  6. $errors = $this->_getParam('error_handler');
  7. if (!$errors || !$errors instanceof ArrayObject) {
  8. $this->view->message = 'You have reached the error page';
  9. return;
  10. }
  11. switch ($errors->type) {
  12. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
  13. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  14. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  15. // 404 error -- controller or action not found
  16. $this->getResponse()->setHttpResponseCode(404);
  17. $priority = Zend_Log::NOTICE;
  18. $this->view->message = 'Page not found';
  19. break;
  20. default:
  21. // application error
  22. $this->getResponse()->setHttpResponseCode(500);
  23. $priority = Zend_Log::CRIT;
  24. $this->view->message = 'Application error';
  25. break;
  26. }
  27. // Log exception, if logger available
  28. if ($log = $this->getLog()) {
  29. $log->log($this->view->message, $priority, $errors->exception);
  30. $log->log('Request Parameters', $priority, $errors->request->getParams());
  31. }
  32. // conditionally display exceptions
  33. if ($this->getInvokeArg('displayExceptions') == true) {
  34. $this->view->exception = $errors->exception;
  35. }
  36. $this->view->request = $errors->request;
  37. }
  38. public function getLog()
  39. {
  40. $bootstrap = $this->getInvokeArg('bootstrap');
  41. if (!$bootstrap->hasResource('Log')) {
  42. return false;
  43. }
  44. $log = $bootstrap->getResource('Log');
  45. return $log;
  46. }
  47. }