From 8c57655124dbccf9f3933d47d308526b189627ee Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Thu, 3 Jul 2014 19:49:43 +0400 Subject: [PATCH] Remove error handler from FrontController --- App/FrontController.php | 77 +++++++++++++++------------------------------- Exception/ErrorHandler.php | 2 +- 2 files changed, 26 insertions(+), 53 deletions(-) diff --git a/App/FrontController.php b/App/FrontController.php index 07ba0eb..8b042ec 100644 --- a/App/FrontController.php +++ b/App/FrontController.php @@ -102,62 +102,35 @@ class FrontController public function execute() { - try { - $request = \Majestic\Env::getRequestUri(true); - $route = $this->getRouter()->route($request); - if (!$route) { - throw new \Majestic\Exception\Error404Exception('Route for "' . $request . '" not found'); - } - - $action_class = $route->getAction(); - if (!class_exists($action_class)) { - throw new \Majestic\Exception\GeneralException('Action class "' . $action_class . '" not found.'); - } + $request = \Majestic\Env::getRequestUri(true); + $route = $this->getRouter()->route($request); + if (!$route) { + throw new \Majestic\Exception\Error404Exception('Route for "' . $request . '" not found'); + } - $action = new $action_class(); - $layout_class = $route->getLayout(); - if (!class_exists($layout_class)) { - throw new \Majestic\Exception\GeneralException('Layout class "' . $layout_class . '" not found.'); - } + $action_class = $route->getAction(); + if (!class_exists($action_class)) { + throw new \Majestic\Exception\GeneralException('Action class "' . $action_class . '" not found.'); + } - /** - * @var \Majestic\Layout\Layout $layout - */ - $layout = new $layout_class(); - $html = $layout->fetch($action); - if (\Majestic\Config::get('PROFILER')) { - if (is_subclass_of($action, 'AjaxAction')) { - \Majestic\Util\Profiler\Profiler::getInstance()->getJson(); - } else { - $html = \Majestic\Util\Profiler\Profiler::getInstance()->end($html); - } - } - return $html; + $action = new $action_class(); + $layout_class = $route->getLayout(); + if (!class_exists($layout_class)) { + throw new \Majestic\Exception\GeneralException('Layout class "' . $layout_class . '" not found.'); } - catch (\Exception $e) { - if (\Majestic\Config::get('DEBUG')) { - if (!headers_sent()) { - if ($e instanceof \Majestic\Exception\ErrorHTTPException) { - header($e->getHTTPHeader()); - } else { - header('HTTP/1.0 500 Internal Server Error'); - } - } - \Majestic\Exception\ErrorHandler::logError($e); - return \Majestic\Exception\ErrorHandler::showDebug($e); - } - $layout_class = $this->getRouter()->getErrorLayout(); - - /** - * @var \Majestic\Layout\ErrorLayout $layout - */ - $layout = new $layout_class(); - $layout->setException($e); - $error_action = new ErrorAction($e); - if (isset($action_class) && is_subclass_of($action_class, 'AjaxAction')) { - $error_action->setAjaxError(); + + /** + * @var \Majestic\Layout\Layout $layout + */ + $layout = new $layout_class(); + $html = $layout->fetch($action); + if (\Majestic\Config::get('PROFILER')) { + if (is_subclass_of($action, 'AjaxAction')) { + \Majestic\Util\Profiler\Profiler::getInstance()->getJson(); + } else { + $html = \Majestic\Util\Profiler\Profiler::getInstance()->end($html); } - return $layout->fetch($error_action); } + return $html; } } \ No newline at end of file diff --git a/Exception/ErrorHandler.php b/Exception/ErrorHandler.php index 6ca3dec..dc3263b 100644 --- a/Exception/ErrorHandler.php +++ b/Exception/ErrorHandler.php @@ -12,7 +12,7 @@ class ErrorHandler static public function init() { - set_error_handler(array('Majestic\Exception\ErrorHandler', 'error_handler')); + //set_error_handler(array('Majestic\Exception\ErrorHandler', 'error_handler')); } static public function error_handler($errno, $errstr, $errfile, $errline)