Added 'system.errors.verbosity' that ideally would replace 'system.errors.display' eventually (#1091)

This commit is contained in:
Aaron Dalton
2016-10-12 16:10:58 -07:00
committed by Andy Miller
parent 6300ab8a03
commit 4f8ac36a9a
2 changed files with 46 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
<?php
/**
* @package Grav.Common.Errors
*
* @copyright Copyright (C) 2014 - 2016 RocketTheme, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
namespace Grav\Common\Errors;
use Whoops\Handler\Handler;
class BareHandler extends Handler
{
/**
* @return int|null
*/
public function handle()
{
return Handler::QUIT;
}
}

View File

@@ -22,16 +22,34 @@ class Errors
// Setup Whoops-based error handler
$whoops = new \Whoops\Run;
if (isset($config['display'])) {
if ($config['display']) {
// Verbosity to eventually replace `display` entirely.
// If not set (legacy config) use `display`.
// Otherwise set to 0.
$verbosity = 0;
if (! isset($config['verbosity'])) {
if ( (isset($config['display'])) && ($config['display']) ) {
$verbosity = 2;
} else {
$verbosity = 1;
}
} else {
$verbosity = $config['verbosity'];
}
switch ($verbosity) {
case 2:
$error_page = new Whoops\Handler\PrettyPageHandler;
$error_page->setPageTitle('Crikey! There was an error...');
$error_page->addResourcePath(GRAV_ROOT . '/system/assets');
$error_page->addCustomCss('whoops.css');
$whoops->pushHandler($error_page);
} else {
break;
case 1:
$whoops->pushHandler(new SimplePageHandler);
}
break;
case 0:
$whoops->pushHandler(new BareHandler);
break;
}
if (method_exists('Whoops\Util\Misc', 'isAjaxRequest')) { //Whoops 2.0