Skip to content

Commit

Permalink
Added 'system.errors.verbosity' that ideally would replace 'system.er…
Browse files Browse the repository at this point in the history
…rors.display' eventually (#1091)
  • Loading branch information
Perlkonig authored and rhukster committed Oct 12, 2016
1 parent 6300ab8 commit 4f8ac36
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
24 changes: 24 additions & 0 deletions system/src/Grav/Common/Errors/BareHandler.php
Original file line number Diff line number Diff line change
@@ -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;
}

}
26 changes: 22 additions & 4 deletions system/src/Grav/Common/Errors/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,34 @@ public function resetHandlers()
// 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
Expand Down

0 comments on commit 4f8ac36

Please sign in to comment.