use PrettyPageHandler to handler errors while installing

This commit is contained in:
printempw 2016-08-10 22:07:10 +08:00
parent a03a515613
commit fba53c1fe5
3 changed files with 17 additions and 4 deletions

View File

@ -72,8 +72,21 @@ class Boot
}
}
public static function registerErrorHandler()
/**
* Register error handler
*
* @param object $handler Push specified whoops handler
* @return void
*/
public static function registerErrorHandler($handler = null)
{
if (!is_null($handler) && $handler instanceof \Whoops\Handler\HandlerInterface) {
$whoops = new \Whoops\Run;
$whoops->pushHandler($handler);
$whoops->register();
return;
}
if ($_ENV['APP_DEBUG'] !== "false") {
// whoops: php errors for cool kids
$whoops = new \Whoops\Run;

View File

@ -13,7 +13,7 @@ require BASE_DIR.'/vendor/autoload.php';
App\Services\Boot::loadServices();
Config::checkPHPVersion();
Boot::loadDotEnv(BASE_DIR);
Boot::registerErrorHandler();
Boot::registerErrorHandler(new \Whoops\Handler\PrettyPageHandler);
Boot::startSession();
$db_config = Config::getDbConfig();
@ -77,7 +77,7 @@ switch ($step) {
$options = require "options.php";
$options['site_name'] = $_POST['sitename'];
$options['site_url'] = Http::getBaseUrl();
$options['version'] = Application::getVersion();
$options['version'] = App::getVersion();
foreach ($options as $key => $value) {
Option::add($key, $value);

View File

@ -13,7 +13,7 @@ require BASE_DIR.'/vendor/autoload.php';
App\Services\Boot::loadServices();
Config::checkPHPVersion();
Boot::loadDotEnv(BASE_DIR);
Boot::registerErrorHandler();
Boot::registerErrorHandler(new \Whoops\Handler\PrettyPageHandler);
Boot::startSession();
$db_config = Config::getDbConfig();