Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding 'system.errors.verbosity' to eventually replace 'system.errors.display' #1091

Merged
merged 1 commit into from
Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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