Index: trunk/core/kernel/application.php =================================================================== diff -u -r2566 -r2581 --- trunk/core/kernel/application.php (.../application.php) (revision 2566) +++ trunk/core/kernel/application.php (.../application.php) (revision 2581) @@ -55,6 +55,13 @@ var $Factory; /** + * Reference to debugger + * + * @var Debugger + */ + var $Debugger = null; + + /** * Holds all phrases used * in code and template * @@ -70,6 +77,13 @@ var $DB; /** + * Maintains list of user-defined error handlers + * + * @var Array + */ + var $errorHandlers = Array(); + + /** * Returns kApplication instance anywhere in the script. * * This method should be used to get single kApplication object instance anywhere in the @@ -125,10 +139,12 @@ { error_reporting(0); ini_set('display_errors', 0); - - set_error_handler( Array(&$this,'handleError') ); } + $error_handler = set_error_handler( Array(&$this,'handleError') ); + if($error_handler) $this->errorHandlers[] = $error_handler; + + $this->DB = new kDBConnection(SQL_TYPE, Array(&$this,'handleSQLError') ); $this->DB->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB); $this->DB->debugMode = $this->isDebugMode(); @@ -1153,6 +1169,26 @@ fwrite($fp, '['.$time.'] #'.$errno.': '.strip_tags($errstr).' in ['.$errfile.'] on line '.$errline."\n"); fclose($fp); } + + if( !$this->errorHandlers ) return true; + + $i = 0; // while (not foreach) because it is array of references in some cases + $eh_count = count($this->errorHandlers); + while($i < $eh_count) + { + if( is_array($this->errorHandlers[$i]) ) + { + $object =& $this->errorHandlers[$i][0]; + $method = $this->errorHandlers[$i][1]; + $object->$method($errno, $errstr, $errfile, $errline, $errcontext); + } + else + { + $function = $this->errorHandlers[$i]; + $function($errno, $errstr, $errfile, $errline, $errcontext); + } + $i++; + } } /**