Merge pull request #124 from getformwork/feature/optional-error-handlers

Add the possibility to not set error handlers for debugging
This commit is contained in:
Giuseppe Criscione 2021-07-06 16:59:57 +02:00 committed by GitHub
commit a577a81f7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 7 deletions

View File

@ -36,6 +36,9 @@ return [
'timezone' => 'UTC',
'week_starts' => 0
],
'errors' => [
'set_handlers' => true
],
'files' => [
'allowed_extensions' => [
'.jpg',

View File

@ -279,11 +279,13 @@ final class Admin
*/
protected function loadErrorHandler(): void
{
$this->errors = new Controllers\ErrorsController();
set_exception_handler(function (Throwable $exception): void {
$this->errors->internalServerError($exception)->send();
throw $exception;
});
if (Formwork::instance()->config()->get('errors.set_handlers')) {
$this->errors = new Controllers\ErrorsController();
set_exception_handler(function (Throwable $exception): void {
$this->errors->internalServerError($exception)->send();
throw $exception;
});
}
}
/**

View File

@ -94,11 +94,10 @@ final class Formwork
{
$this->initializeSingleton();
Errors::setHandlers();
$this->request = Uri::removeQuery(HTTPRequest::uri());
$this->loadConfig();
$this->loadErrorHandlers();
$this->loadLanguages();
$this->loadTranslations();
$this->loadSchemes();
@ -225,6 +224,16 @@ final class Formwork
date_default_timezone_set($this->config->get('date.timezone'));
}
/**
* Load error handlers
*/
protected function loadErrorHandlers(): void
{
if ($this->config()->get('errors.set_handlers')) {
Errors::setHandlers();
}
}
/**
* Load language from request
*/