mirror of
https://github.com/getgrav/grav.git
synced 2026-03-04 19:41:36 +01:00
Added 'system.errors.verbosity' that ideally would replace 'system.errors.display' eventually (#1091)
This commit is contained in:
committed by
Andy Miller
parent
6300ab8a03
commit
4f8ac36a9a
24
system/src/Grav/Common/Errors/BareHandler.php
Normal file
24
system/src/Grav/Common/Errors/BareHandler.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user