diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-05-24 08:39:20 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-11-02 09:49:37 +0100 |
commit | 052dcdebe8e2c287933caaac379f56423b1ab660 (patch) | |
tree | 2e7808caffa218ba328f2cec2cebf84d8b7d176e /lib/base.php | |
parent | 77c6d248825bf1bda5c0bb48a8d6fc195e139bc6 (diff) | |
download | nextcloud-server-052dcdebe8e2c287933caaac379f56423b1ab660.tar.gz nextcloud-server-052dcdebe8e2c287933caaac379f56423b1ab660.zip |
Refactor the ErrorHandler into a dynamic class
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/base.php')
-rw-r--r-- | lib/base.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/base.php b/lib/base.php index 04c456a12d8..fa69a7d6076 100644 --- a/lib/base.php +++ b/lib/base.php @@ -662,9 +662,20 @@ class OC { $config = \OC::$server->get(\OCP\IConfig::class); if (!defined('PHPUNIT_RUN')) { - OC\Log\ErrorHandler::setLogger(\OC::$server->getLogger()); - $debug = $config->getSystemValue('debug', false); - OC\Log\ErrorHandler::register($debug); + $errorHandler = new OC\Log\ErrorHandler( + \OCP\Server::get(\Psr\Log\LoggerInterface::class), + ); + $exceptionHandler = [$errorHandler, 'onException']; + if ($config->getSystemValue('debug', false)) { + set_error_handler([$errorHandler, 'onAll'], E_ALL); + if (\OC::$CLI) { + $exceptionHandler = ['OC_Template', 'printExceptionErrorPage']; + } + } else { + set_error_handler([$errorHandler, 'onError']); + } + register_shutdown_function([$errorHandler, 'onShutdown']); + set_exception_handler($exceptionHandler); } /** @var \OC\AppFramework\Bootstrap\Coordinator $bootstrapCoordinator */ |