Skip to content

Commit

Permalink
Tweaks for PR #1091 - using same 'display' setting and values 1,0,-1 …
Browse files Browse the repository at this point in the history
…for full backwards compatibility (even on save)
  • Loading branch information
rhukster committed Oct 12, 2016
1 parent 05bd715 commit 5143941
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* Updated vendor libs including Twig `1.25.0`
* Avoid git ignoring any vendor folder in a Grav site subfolder (but still ignore the main `vendor/` folder)
* Added an option to get just a route back from `Uri::convertUrl()` function
* Added option to control split session [#1096](https://github.com/getgrav/grav/pull/1096)
* Added new `verbosity` levels to `system.error.display` to allow for system error messages [#1091](https://github.com/getgrav/grav/pull/1091)
1. [](#bugfix)
* Fixed missing `progress` method in the DirectInstall Command
* `Response` class now handles better unsuccessful requests such as 404 and 401
Expand Down
13 changes: 7 additions & 6 deletions system/blueprints/config/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -764,15 +764,16 @@ form:

fields:
errors.display:
type: toggle
type: select
label: PLUGIN_ADMIN.DISPLAY_ERRORS
help: PLUGIN_ADMIN.DISPLAY_ERRORS_HELP
highlight: 0
size: medium
highlight: 1
options:
1: PLUGIN_ADMIN.YES
0: PLUGIN_ADMIN.NO
validate:
type: bool
-1: PLUGIN_ADMIN.ERROR_SYSTEM
0: PLUGIN_ADMIN.ERROR_SIMPLE
1: PLUGIN_ADMIN.ERROR_FULL_BACKTRACE


errors.log:
type: toggle
Expand Down
2 changes: 1 addition & 1 deletion system/config/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ assets: # Configuration for Assets Manager (
jquery: system://assets/jquery/jquery-2.x.min.js

errors:
display: false # Display full backtrace-style error page
display: 0 # Display either (1) Full backtrace | (0) Simple Error | (-1) System Error
log: true # Log errors to /logs folder

debugger:
Expand Down
26 changes: 11 additions & 15 deletions system/src/Grav/Common/Errors/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,30 @@ public function resetHandlers()
// Setup Whoops-based error handler
$whoops = new \Whoops\Run;

// 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;
$verbosity = 1;

if (isset($config['display'])) {
if (is_int($config['display'])) {
$verbosity = $config['display'];
} else {
$verbosity = 1;
$verbosity = $config['display'] ? 1 : 0;
}
} else {
$verbosity = $config['verbosity'];
}

switch ($verbosity) {
case 2:
case 1:
$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);
break;
case 1:
$whoops->pushHandler(new SimplePageHandler);
break;
case 0:
case -1:
$whoops->pushHandler(new BareHandler);
break;
default:
$whoops->pushHandler(new SimplePageHandler);
break;
}

if (method_exists('Whoops\Util\Misc', 'isAjaxRequest')) { //Whoops 2.0
Expand Down

0 comments on commit 5143941

Please sign in to comment.