From d833d2766f28f927cb4e1e8e660771361abdfdf9 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 17 Nov 2005 19:21:21 +0000 Subject: added application mode support. --- framework/Exceptions/TErrorHandler.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'framework/Exceptions/TErrorHandler.php') diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php index 47feb54c..af41e056 100644 --- a/framework/Exceptions/TErrorHandler.php +++ b/framework/Exceptions/TErrorHandler.php @@ -39,11 +39,23 @@ class TErrorHandler extends TComponent implements IModule public function handleError($sender,$param) { - $type='Unhandled Exception'; - $this->displayException($param,$type); + if(($response=Prado::getApplication()->getResponse())!==null) + $response->clear(); + switch(Prado::getApplication()->getMode()) + { + case 'Off': + case 'Debug': + $this->displayException($param); + exit(1); + case 'Normal': + case 'Performance': + error_log($param->__toString()); + header("HTTP/1.0 500 Internal Error"); + exit(1); + } } - protected function displayException($exception,$type) + protected function displayException($exception) { $lines=file($exception->getFile()); $errorLine=$exception->getLine(); @@ -66,7 +78,8 @@ class TErrorHandler extends TComponent implements IModule '%%SourceFile%%', '%%SourceCode%%', '%%StackTrace%%', - '%%Version%%' + '%%Version%%', + '%%Time%%' ); $values=array( get_class($exception), @@ -74,7 +87,8 @@ class TErrorHandler extends TComponent implements IModule htmlspecialchars($exception->getFile()).' ('.$exception->getLine().')', $source, htmlspecialchars($exception->getTraceAsString()), - $_SERVER['SERVER_SOFTWARE'].' PRADO/'.Prado::getVersion() + $_SERVER['SERVER_SOFTWARE'].' PRADO/'.Prado::getVersion(), + strftime('%Y-%m-%d %H:%m',time()) ); $languages=Prado::getUserLanguages(); $errorFile=dirname(__FILE__).'/error.'.$languages[0]; -- cgit v1.2.3