From 8acf7ab3b43115c02f9c3337d3ea905b42b327a2 Mon Sep 17 00:00:00 2001 From: Chema Date: Tue, 20 Oct 2015 10:15:08 +0200 Subject: [PATCH] PHP7 - Uncaught TypeError - Exception.php Closes https://github.com/kohana/core/issues/642 --- classes/Kohana/Kohana/Exception.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/classes/Kohana/Kohana/Exception.php b/classes/Kohana/Kohana/Exception.php index d11a2f403..f136a7ae8 100644 --- a/classes/Kohana/Kohana/Exception.php +++ b/classes/Kohana/Kohana/Exception.php @@ -81,7 +81,7 @@ public function __toString() * @param Exception $e * @return void */ - public static function handler(Exception $e) + public static function handler($e) { $response = Kohana_Exception::_handler($e); @@ -99,7 +99,7 @@ public static function handler(Exception $e) * @param Exception $e * @return Response */ - public static function _handler(Exception $e) + public static function _handler($e) { try { @@ -137,7 +137,7 @@ public static function _handler(Exception $e) * @param int $level * @return void */ - public static function log(Exception $e, $level = Log::EMERGENCY) + public static function log($e, $level = Log::EMERGENCY) { if (is_object(Kohana::$log)) { @@ -160,8 +160,11 @@ public static function log(Exception $e, $level = Log::EMERGENCY) * @param Exception $e * @return string */ - public static function text(Exception $e) + public static function text($e) { + if ( ! $e instanceof Exception AND ! $e instanceof Throwable ) + throw InvalidArgumentException; + return sprintf('%s [ %s ]: %s ~ %s [ %d ]', get_class($e), $e->getCode(), strip_tags($e->getMessage()), Debug::path($e->getFile()), $e->getLine()); } @@ -173,8 +176,11 @@ public static function text(Exception $e) * @param Exception $e * @return Response */ - public static function response(Exception $e) + public static function response($e) { + if ( ! $e instanceof Exception AND ! $e instanceof Throwable ) + throw InvalidArgumentException; + try { // Get the exception information