From 9b6663f87a7e679ffba691cf516191fc840cf978 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 24 Nov 2009 19:20:36 -0800 Subject: Update to Kohana r4684 which is now Kohana 2.4 and has substantial changes. --- system/libraries/Kohana_PHP_Exception.php | 99 +++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 system/libraries/Kohana_PHP_Exception.php (limited to 'system/libraries/Kohana_PHP_Exception.php') diff --git a/system/libraries/Kohana_PHP_Exception.php b/system/libraries/Kohana_PHP_Exception.php new file mode 100644 index 00000000..fca5b30b --- /dev/null +++ b/system/libraries/Kohana_PHP_Exception.php @@ -0,0 +1,99 @@ +code = $code; + $this->file = $file; + $this->line = $line; + } + + /** + * PHP error handler. + * + * @throws Kohana_PHP_Exception + * @return void + */ + public static function error_handler($code, $error, $file, $line, $context = NULL) + { + // Respect error_reporting settings + if (error_reporting() & $code) + { + // Throw an exception + throw new Kohana_PHP_Exception($code, $error, $file, $line, $context); + } + } + + /** + * Catches errors that are not caught by the error handler, such as E_PARSE. + * + * @uses Kohana_Exception::handle() + * @return void + */ + public static function shutdown_handler() + { + if (Kohana_PHP_Exception::$enabled AND $error = error_get_last()) + { + // Fake an exception for nice debugging + Kohana_Exception::handle(new Kohana_PHP_Exception($error['type'], $error['message'], $error['file'], $error['line'])); + } + } + +} // End Kohana PHP Exception -- cgit v1.2.3