PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/demos/Zend/Cloud/cloudexp/application/controllers/ErrorController.php

https://bitbucket.org/ksekar/campus
PHP | 73 lines | 36 code | 7 blank | 30 comment | 5 complexity | d7adfd3390a97641f76e033122dcb367 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Cloud
  17. * @subpackage examples
  18. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @category Zend
  23. * @package Zend_Cloud
  24. * @subpackage examples
  25. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  26. * @license http://framework.zend.com/license/new-bsd New BSD License
  27. */
  28. class ErrorController extends Zend_Controller_Action
  29. {
  30. public function errorAction()
  31. {
  32. $errors = $this->_getParam('error_handler');
  33. switch ($errors->type) {
  34. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
  35. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
  36. case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
  37. // 404 error -- controller or action not found
  38. $this->getResponse()->setHttpResponseCode(404);
  39. $this->view->message = 'Page not found';
  40. break;
  41. default:
  42. // application error
  43. $this->getResponse()->setHttpResponseCode(500);
  44. $this->view->message = 'Application error';
  45. break;
  46. }
  47. // Log exception, if logger available
  48. if ($log = $this->getLog()) {
  49. $log->crit($this->view->message, $errors->exception);
  50. }
  51. // conditionally display exceptions
  52. if ($this->getInvokeArg('displayExceptions') == true) {
  53. $this->view->exception = $errors->exception;
  54. }
  55. $this->view->request = $errors->request;
  56. }
  57. public function getLog()
  58. {
  59. $bootstrap = $this->getInvokeArg('bootstrap');
  60. if (!$bootstrap->hasPluginResource('Log')) {
  61. return false;
  62. }
  63. $log = $bootstrap->getResource('Log');
  64. return $log;
  65. }
  66. }