sintonia/airtime_mvc/application/controllers/ErrorController.php
Albert Santoni 11c6818e61 Merge branch '2.5.x-installer' into saas-installer-albert
Conflicts:
	.gitignore
	airtime_mvc/application/Bootstrap.php
	airtime_mvc/application/configs/conf.php
	airtime_mvc/application/controllers/SystemstatusController.php
	airtime_mvc/application/controllers/UpgradeController.php
	airtime_mvc/application/upgrade/Upgrades.php
	airtime_mvc/application/views/scripts/systemstatus/index.phtml
	airtime_mvc/build/airtime.conf
	airtime_mvc/build/sql/defaultdata.sql
	airtime_mvc/public/index.php
	airtime_mvc/tests/application/helpers/AirtimeInstall.php
	install_minimal/airtime-install
	install_minimal/include/airtime-constants.php
	install_minimal/include/airtime-copy-files.sh
	install_minimal/include/airtime-db-install.php
	install_minimal/include/airtime-initialize.sh
	install_minimal/include/airtime-install.php
	install_minimal/include/airtime-installed-check.php
	install_minimal/include/airtime-remove-files.sh
	install_minimal/include/airtime-upgrade.php
	python_apps/media-monitor/install/media-monitor-copy-files.py
	python_apps/monit/monit-airtime-generic.cfg
	python_apps/pypo/airtime-playout
	python_apps/pypo/install/pypo-copy-files.py
	python_apps/pypo/liquidsoap/generate_liquidsoap_cfg.py
	python_apps/pypo/liquidsoap/ls_script.liq
	python_apps/pypo/pypo/__main__.py
	python_apps/pypo/pypo/media/update/replaygain.py
	python_apps/pypo/pypo/media/update/replaygainupdater.py
	python_apps/pypo/pypo/media/update/silananalyzer.py
	python_apps/python-virtualenv/airtime_virtual_env.pybundle
	python_apps/python-virtualenv/requirements
	utils/airtime-check-system.php
2015-05-22 16:05:29 -04:00

112 lines
3.6 KiB
PHP

<?php
class ErrorController extends Zend_Controller_Action {
public function init()
{
//The default layout includes the Dashboard header, which may contain private information.
//We cannot show that.
$this->view->layout()->disableLayout();
$this->setupCSS();
}
public function errorAction() {
$errors = $this->_getParam('error_handler');
if ($errors) {
// log error message and stack trace
Logging::error($errors->exception->getMessage());
Logging::error($errors->exception->getTraceAsString());
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE :
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER :
$this->error404Action();
break;
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION :
$this->error400Action();
break;
default :
$this->error500Action();
break;
}
} else {
$exceptions = $this->_getAllParams();
Logging::error($exceptions);
$this->error500Action();
return;
}
// Log exception, if logger available
/* No idea why this doesn't work or why it was implemented like this. Disabling it -- Albert
if (($log = $this->getLog())) {
$log->crit($this->view->message, $errors->exception);
}*/
//Logging that actually works: -- Albert
Logging::error($this->view->message . ": " . $errors->exception);
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}
private function setupCSS()
{
$CC_CONFIG = Config::getConfig();
$staticBaseDir = Application_Common_OsPath::formatDirectoryWithDirectorySeparators($CC_CONFIG['staticBaseDir']);
$this->view->headLink()->appendStylesheet($staticBaseDir . 'css/styles.css?' . $CC_CONFIG['airtime_version']);
}
public function getLog() {
$bootstrap = $this->getInvokeArg('bootstrap');
if (!$bootstrap->hasPluginResource('Log')) {
return false;
}
$log = $bootstrap->getResource('Log');
return $log;
}
/**
* 404 error - route or controller
*/
public function error404Action() {
$this->_helper->viewRenderer('error-404');
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = _('Page not found.');
}
/**
* 400 error - no such action
*/
public function error400Action() {
$this->_helper->viewRenderer('error-400');
$this->getResponse()->setHttpResponseCode(400);
$this->view->message = _('The requested action is not supported.');
}
/**
* 403 error - permission denied
*/
public function error403Action() {
$this->_helper->viewRenderer('error-403');
$this->getResponse()->setHttpResponseCode(403);
$this->view->message = _('You do not have permission to access this resource.');
}
/**
* 500 error - internal server error
*/
public function error500Action() {
$this->_helper->viewRenderer('error-500');
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = _('An internal application error has occurred.');
}
}