/** * Custom JError callback * * Push the exception call stack in the JException returned through the call back * adn then rener the custom error page * * @param object A JException object * @return void */ public function errorHandler($error) { if ($error instanceof Exception) { $exception = $error; $this->_exception = $exception; //store the exception for later use //Make sure we have a valid status code JError::raiseError(KHttpResponse::isError($exception->getCode()) ? $exception->getCode() : 500, $exception->getMessage()); return; } $error->setProperties(array('backtrace' => $this->_exception->getTrace(), 'file' => $this->_exception->getFile(), 'line' => $this->_exception->getLine())); $debug = version_compare(JVERSION, '3.0', 'ge') ? JFactory::getConfig()->get('debug') : JFactory::getConfig()->getValue('config.debug'); if ($debug) { $error->set('message', (string) $this->_exception); } else { $error->set('message', KHttpResponse::getMessage($error->get('code'))); } //Make sure the buffers are cleared while (@ob_get_clean()) { } JError::customErrorPage($error); }
/** * Catch all exception handler * * Calls the Joomla error handler to process the exception * * @param object an Exception object * @return void */ public function exceptionHandler($exception) { $this->_exception = $exception; //store the exception for later use //Change the Joomla error handler to our own local handler and call it JError::setErrorHandling( E_ERROR, 'callback', array($this,'errorHandler')); //Make sure we have a valid status code JError::raiseError(KHttpResponse::isError($exception->getCode()) ? $exception->getCode() : 500, $exception->getMessage()); }