public static function register($debug = true)
{
$errorLevels = error_reporting();
if ($debug) {
$errorLevels |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
Debug\DebugClassLoader::enable();
}
if (PHP_SAPI !== 'cli') {
Debug\ErrorHandler::register()->throwAt($errorLevels, true);
Debug\ExceptionHandler::register($debug);
} else {
$consoleHandler = function (\Exception $e) {
$app = new Application('Bolt CLI', Version::VERSION);
$output = new ConsoleOutput(OutputInterface::VERBOSITY_DEBUG);
$app->renderException($e, $output);
ob_clean();
};
Debug\ExceptionHandler::register($debug)->setHandler($consoleHandler);
}
}