diff options
-rw-r--r-- | console.php | 11 | ||||
-rw-r--r-- | lib/base.php | 11 | ||||
-rw-r--r-- | lib/private/log/errorhandler.php | 3 |
3 files changed, 14 insertions, 11 deletions
diff --git a/console.php b/console.php index fc571b03f1e..9d2271db9f2 100644 --- a/console.php +++ b/console.php @@ -42,6 +42,11 @@ if (version_compare(PHP_VERSION, '5.4.0') === -1) { return; } +function exceptionHandler($exception) { + echo "An unhandled exception has been thrown:" . PHP_EOL; + echo $exception; + exit(1); +} try { require_once 'lib/base.php'; @@ -53,6 +58,8 @@ try { exit(0); } + set_exception_handler('exceptionHandler'); + if (!OC_Util::runningOnWindows()) { if (!function_exists('posix_getuid')) { echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL; @@ -87,7 +94,5 @@ try { $application->loadCommands(new ArgvInput(), new ConsoleOutput()); $application->run(); } catch (Exception $ex) { - echo "An unhandled exception has been thrown:" . PHP_EOL; - echo $ex; - exit(1); + exceptionHandler($ex); } diff --git a/lib/base.php b/lib/base.php index 27967588360..708229a8e7f 100644 --- a/lib/base.php +++ b/lib/base.php @@ -545,14 +545,9 @@ class OC { OC_Util::isSetLocaleWorking(); if (!defined('PHPUNIT_RUN')) { - $logger = \OC::$server->getLogger(); - OC\Log\ErrorHandler::setLogger($logger); - if (\OC::$server->getConfig()->getSystemValue('debug', false)) { - OC\Log\ErrorHandler::register(true); - set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); - } else { - OC\Log\ErrorHandler::register(); - } + OC\Log\ErrorHandler::setLogger(\OC::$server->getLogger()); + $debug = \OC::$server->getConfig()->getSystemValue('debug', false); + OC\Log\ErrorHandler::register($debug); } // register the stream wrappers diff --git a/lib/private/log/errorhandler.php b/lib/private/log/errorhandler.php index 27cde4aa242..8899bcfcb03 100644 --- a/lib/private/log/errorhandler.php +++ b/lib/private/log/errorhandler.php @@ -44,6 +44,9 @@ class ErrorHandler { if ($debug) { set_error_handler(array($handler, 'onAll'), E_ALL); + if (\OC::$CLI) { + set_exception_handler(array('OC_Template', 'printExceptionErrorPage')); + } } else { set_error_handler(array($handler, 'onError')); } |