diff --git a/src/Application/Application.php b/src/Application/Application.php index d7cb9992e..2323a4647 100644 --- a/src/Application/Application.php +++ b/src/Application/Application.php @@ -90,7 +90,9 @@ public function run() } catch (\Exception $e) { $this->onError($this, $e); - if ($this->catchExceptions && $this->errorPresenter) { + + // if catchExceptions is NULL, catch only BadRequestException + if (($this->catchExceptions || ($this->catchExceptions === NULL && $e instanceof BadRequestException)) && $this->errorPresenter) { try { $this->processException($e); $this->onShutdown($this, $e); diff --git a/src/Bridges/ApplicationDI/ApplicationExtension.php b/src/Bridges/ApplicationDI/ApplicationExtension.php index 48f05f745..e1817c1ce 100644 --- a/src/Bridges/ApplicationDI/ApplicationExtension.php +++ b/src/Bridges/ApplicationDI/ApplicationExtension.php @@ -21,7 +21,7 @@ class ApplicationExtension extends Nette\DI\CompilerExtension public $defaults = array( 'debugger' => TRUE, 'errorPresenter' => 'Nette:Error', - 'catchExceptions' => NULL, + 'catchExceptions' => NULL, // true|false|smart 'mapping' => NULL, 'scanDirs' => array(), 'scanComposer' => NULL, @@ -49,7 +49,7 @@ public function loadConfiguration() $application = $container->addDefinition($this->prefix('application')) ->setClass('Nette\Application\Application') - ->addSetup('$catchExceptions', array($config['catchExceptions'])) + ->addSetup('$catchExceptions', array($config['catchExceptions'] === 'smart' ? NULL : $config['catchExceptions'])) ->addSetup('$errorPresenter', array($config['errorPresenter'])); if ($config['debugger']) {