KumbiaPHP beta2-dev
Framework PHP en español
|
00001 <?php 00022 class KumbiaException extends Exception { 00028 protected $_view; 00029 00036 public function __construct($message, $view = 'exception') { 00037 $this->_view = $view; 00038 parent::__construct($message); 00039 } 00040 00046 public static function handle_exception($e) 00047 { 00048 if(isset($e->_view) && ($e->_view == 'no_controller' || $e->_view == 'no_action')) { 00049 header('HTTP/1.1 404 Not Found'); 00050 } else { 00051 header('HTTP/1.1 500 Internal Server Error'); 00052 } 00053 00054 extract(Router::get(), EXTR_OVERWRITE); 00055 00056 $Controller = Util::camelcase($controller); 00057 ob_start(); 00058 if(PRODUCTION) { 00059 include APP_PATH . 'views/_shared/errors/404.phtml'; 00060 return; 00061 } else { 00062 $Template = 'views/templates/exception.phtml'; 00063 if(isset($e->_view)) { 00064 include CORE_PATH . "views/errors/{$e->_view}.phtml"; 00065 } else { 00066 include CORE_PATH . "views/errors/exception.phtml"; 00067 } 00068 } 00069 $content = ob_get_clean(); 00070 00071 // termina los buffers abiertos 00072 while(ob_get_level()) { 00073 ob_end_clean(); 00074 } 00075 00076 // verifica si esta cargado el View 00077 if(class_exists('View')) { 00078 if(View::get('template') === NULL) { 00079 echo $content; 00080 exit; 00081 } 00082 } 00083 00084 include CORE_PATH . $Template; 00085 } 00086 }